开发者

Jquery - Append to ID

开发者_开发百科Do to an IE6 bug I need to alter some Jquery,

I want to take an element called #nav, append to the ID.

I already use addClass to create <div id="#nav" class="test">

$('span .breadcrumb').each(function(){
    $('#Nav').addClass($(this).text());

Which takes the breadcrumb navigation text and adds it as a new class to the

Can i use .append to add the text to the ID?


Just change the id attribute:

$('#nav').attr('id','nav' + appendString);

Where appendString contains whatever you want to append.


Append adds to the content of the element, not its attributes. To do what you're after, I'd use the following:

$('#nav').attr('id', 'nav' + 'appendedString');


It should work.

$(this).attr('id', $(this).attr('id') + $(this).text() );

Or whatever you need to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜