English 中文(简体)
页: 1 Qu在点击时获得下一个微粒隐藏值
原标题:jQuery get the next sibling hidden value on click
  • 时间:2011-09-30 09:07:05
  •  标签:
  • jquery

我试图在点击连接事件时获得隐蔽的实地价值。 这些要素是:

<p>
    <a class="showCommentAttachment cboxElement" href="#">Attachments</a>
    <input type="hidden" value="13" id="ctl00_ContentPlaceHolder1_lvComment_ctrl3_hfCommentId" name="ctl00$ContentPlaceHolder1$lvComment$ctrl3$hfCommentId">
</p>

这里是完整的标记:

<div id="divComment" class="comment-text">
    <div class="comment-author">
         David Chart
    </div>
    <span class="comment-date-time">Sep 29, 2011 08:12:42 PM</span>
    <p>
         Some comment text goes here. Some comment text goes here.

    </p>
    <p>
        <a class="showCommentAttachment cboxElement" href="#">Attachments</a>
        <input type="hidden" value="13" id="ctl00_ContentPlaceHolder1_lvComment_ctrl3_hfCommentId" name="ctl00$ContentPlaceHolder1$lvComment$ctrl3$hfCommentId">
    </p>
</div>

Here s the jQuery:

$("#divComment a.showCommentAttachment").click(function() {

    var nextSibling = $(this).next().find( input:hidden ).val();

    $("#showCommentId").html(nextSibling + "<-- Here s the comment ID ");

 });

what I get back from nextSibling is undefined. I tried with nexAll like this

var nextSibling =美元(这里)。

尚未确定。

谢谢。

最佳回答

您应仅使用<代码>$(这一条)。 另外,还有<代码>$(该文本)。 http://api.jquery.com/find/“rel=“noreferer” 简历

.find(

Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element.

因此,您需要<代码>$.next.val()。

问题回答

<代码>next(>> 给您下一个折合点,即投入领域本身。 电话.find() 查询该领域的后代(无)。

You just want $(this).next().val()

please try:

$(this).next().val();

$("#divComment a.showCommentAttachment").next().val();




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签