Sunday, 15 September 2013

jQuery: Selecting the inner html of an elemnt with a specific value and assign it to a variable? -



jQuery: Selecting the inner html of an elemnt with a specific value and assign it to a variable? -

i have code:

<dl class="item-options"> <dt>dt1</dt> <dd>dd1</dd> <dt>dt2</dt> <dd>ss2</dd> </dl>

now want access dt1 content , assign value dd1 it. iterating on dds in each loop, each dd access, want content matching dt.

any ideas how that?

thanks!

try:

var = $(".item-options dt").first().text());

http://jsfiddle.net/hyskp/

if dt1 isn't first element, loop on each dt:

$("dt").each(function(e) { var dt = $(this).text(); if (dt == "dt1") { // logic } });

http://jsfiddle.net/xerbm/

jquery

No comments:

Post a Comment