开发者

Jquery toggle separately

开发者 https://www.devze.com 2023-03-31 05:45 出处:网络
I\'m trying to use Toggle my co开发者_如何学Cntents under separate list items. But what s the best method to implement this in a generic way.

I'm trying to use Toggle my co开发者_如何学Cntents under separate list items. But what s the best method to implement this in a generic way. I dont want to give each content a separate class or id

http://jsfiddle.net/kKDWR/6/


You can use the jQuery selector children. Try this example:

http://jsfiddle.net/kKDWR/8/

Or you can use .find()


You make use of jQuery ... and you implement your feature in a jquery way. There's nothing wrong with it.

I'd only recommend to have a parent element (propably your current <UL>) with an ID (for example <ul id="forum_entries>"). So you can address the items as $(".tog", "#forum_entries"). This can be much faster than simply addressing by classname, if your document becomes large.

0

精彩评论

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