javascript - Rainbow Effect not working correctly with A hrefs -


i have code trying write website host, member asked support. , wrote this, , works text hrefs ruins markup.

http://jsbin.com/izebej/1/edit

code:

  $.getscript("http://xoxco.com/projects/code/rainbow/rainbow.js",function() {       var selectme= ["u1","u2"];    for(var =0;i<selectme.length;i++){      $('.username').find('a[href*='+selectme[i]+']').addclass('selected');     }    $('.selected').text(function() {         $(this).rainbow({     colors: [       '#ff0000',       '#f26522',       '#fff200',       '#00a651',       '#28abe2',       '#2e3192',       '#6868ff'      ],       animate:true,       animateinterval:100,       pad:false,       pauselength:100        });      });    }); 

the markup in jsbin- can see happening. i've tried many different ways. if @ markup marked href last 1 u21, seeing object wrote u1 , u2. combining them see if looking 1 or 2 in it. in loop see a[href*='+selectme[i]+' i've changed a[href='selectme[i]' a[href="'+selectme[i]+'" yet not work.

any suggestions?

@easybb tried see it, saw no problem rainbow effect see everywhere...

if mean , strong should not seen in rainbow... text inside span... way plugin works.

if see plug in code...

if (chars[x]!=' ') {      newstr = newstr + '<span style="color: ' + options.colors[counter] + ';">' + chars[x] + '</span>';      counter++; } else {     newstr = newstr + ' ';  } 

what they break html content of element , apply colors them adding span...

so <span> test </span> becomes <span color="x"> < </span><span color="x"> s </span> , on don`t remain as html mark simple text...

i think best bet find elements direct parents of text

demo

$.getscript("http://xoxco.com/projects/code/rainbow/rainbow.js",function() { var selectme= ["u1","u2"]; for(var =0;i<selectme.length;i++){ $('.username').find('a[href*="'+selectme[i]+'"]').addclass('selected'); }   $('.selected').find('*').andself().contents().filter(function(){    return this.nodetype===3;   }).parent().text(function() {     $(this).rainbow({   colors: [   '#ff0000',   '#f26522',   '#fff200',   '#00a651',   '#28abe2',   '#2e3192',   '#6868ff'   ], animate:true, animateinterval:100, pad:false, pauselength:100 }); }); }); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -