获取jQuery中的输入值 [英] Get value of input in jQuery

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

问题描述

我想在点击一个复选框时重定向到另一个页面。

I want to redirect to another page when a checkbox is clicked.

<script type="text/javascript"><!--
$(document).ready(function(){
    jQuery(".cbno").click(function(e){
        e.preventDefault();
        alert('test');
        alert(this.val());
//      window.location = this.val();
    });
});
//-->
</script>

<input type="checkbox" class="cbno" name="content" value="/map/?filter=all" />

非常简单 - 但我无法弄清楚为什么第二个警报不产生任何输出?
Internet Explorer说:该对象不支持val方法。

Pretty simple - but I cannot figure out why the second alert does not produce any output? Internet Explorer says: "The object does not support the method val".

如果我使用this.getAttribute('value')它会起作用 - 为什么呢它不适用于jquery val()?

It works if I use this.getAttribute('value') - why does it not work with the jquery val()?

推荐答案

使用

alert(jQuery(this).val());

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

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