jquery获取下一个类实例的值

时间:2016-04-10 15:02:37

标签: javascript jquery

我正在尝试使用jQuery来获取具有more_details_conmore_details_descmore_details_res类的div的值,并且当点击edit_entry但我没有&# 39;我认为我正在遍历DOM,因为警报只是说未定义。

HTML

<div class="details">
    <span class="id">1234</span>
    <span class="contact">account name</span>
</div>

<div class = "more_details">
    <div class = "more_details_btns">
        <div class="go_account">Go to Account</div>
        <div class="edit_entry">Edit</div>
        <div class="delete_entry">Delete</div>
    </div>
    <div class="container">
        <div class="more_details_title">Contact:</div>
        <div class="more_details_con">Contact name</div>
        <p class="clear"></p>
    </div>
    <div class="container">
        <div class="more_details_title">Description:</div>
        <div class="more_details_desc">Actual Description</div>
        <p class="clear">
    </div>
    <div class="container">
        <div class="more_details_title">Resolution:</div>
        <div class="more_details_res">Actual Resolution</div>
        <p class="clear">
    </div>
</div>

我试过的jQuery

$("#results").on("click", ".edit_entry", function() {
    var contact = $(this).next(".more_details_con").html();
    var desc = $(this).next(".more_details_desc").html();
    var res = $(this).next(".more_details_res").html();
    alert(contact+desc+res);
});

0 个答案:

没有答案