mtest wrote:

: How I can add ID like I add class by function addClass?

    You can't. IDs are one-to-one relationships with their tags.
addClass adds a class to a tag which may already have another
class. Each tag can have many classes.

    An addID method would allow more than one ID per tag, which
breaks the rules of CSS. What your example implies is that you 
need a way to change an ID attribute to a set of html tags.


: For example i have:
: 
: <div>Some text #1</div>
: <div>Some text #2</div>
: 
: And i want see this result:
: <div id="Div1">Some text #1</div>
: <div id="Div2">Some text #2</div>
: 
: I don't know how make this, please help.
: Maybe like this :):
: 
: $(document).ready(function() {
:    var i = 1;
:    $("div").each(function(){
:        this.addID("Div"+ "1");
:    });
: });


    $(document).ready(function(){
        $('div').each( function(i){
            $(this).attr({ id: 'div' + ++i });
        })
    });

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

http://www.clarksonenergyhomes.com/wordpress/about/

Reply via email to