jQuery获取.val [英] Jquery get .val

查看:75
本文介绍了jQuery获取.val的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要的是的"this"值

What I need is the "this" value of

( $(this).attr("value")); 

出现在

$("#activities_" +btn_id).val($(this).val());

这是代码.

$('.thoughts_list').click(function(){
    ( $(this).attr('id'));
    ( $(this).attr("value"));
}); 
    $('#close_thoughts').click(function(){

    $("#activities_" +btn_id).val($(this).val());   
}); 

当前,返回的值是取消",即"#close_thoughts"的值,相反,我需要单击的".thoughts列表"的值

Currently, the value that is returned is "Cancel", which is the value of the "#close_thoughts", instead I need the value of the clicked ".thoughts list"

回答,这显然是我想要的.

ANSWERED, apperantly this is what i was looking for.

$('.thoughts_list').click(function(){
    ( $(this).attr('id'));
    ( $(this).attr("value"));
}); 
    $('#close_thoughts').click(function(){

    $("#activities_" +btn_id).val($('input[name=thoughts_list]:checked').val());    
}); 

推荐答案

这是我老板给我工作的.

This is what my boss gave me to work with.

$('.thoughts_list').click(function(){
    ( $(this).attr('id'));
    ( $(this).attr("value"));
}); 
    $('#close_thoughts').click(function(){

    $("#activities_" +btn_id).val($('input[name=thoughts_list]:checked').val());    
}); 

这篇关于jQuery获取.val的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆