开发者

Find element using jQuery

I've got some HTML that looks like this.

<li class="t-item t-first">
  <div class="t-top">
    <span class="t-icon t-plus"></span>
   开发者_开发技巧 <span class="t-in">Offshore</span>
  </div>
  <input type="hidden" value="41393" name="itemValue" class="t-input">
</li>

The HTML is a single item from a treeview created by Telerik. The real data here is that "Offshore" has an id of "41393".

From the Telerik code I get the span-element with class"t-in", but I'm unable to get the ID-value from it. How can I use jQuery to find the value of the hidden input type?


how about this:

var $in = $(".t-in");
var text = $in.text(); //offshore
var val = $in.parent(".t-item").find("input.t-input").val() //41393

this sorta works if you only have one t-in element, otherwise, you have have to replace the first line in my code with how you select the element yourself.

You need to provide more info, but this is the best i could do with what you gave


How about this:

var offShoreId = $("span.t-in").each(function() {
                  if ($(this).val() == "Offshore") return $(this).parent().next().val();
                }

I'm assuming that all you want is the value of the Offshore element from a large tree of elements.


Thanks for the suggestions guys, here is what I ended up with.

$(e.item).parent().find('input').val();

where e is the element Telerik gave me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜