[英]I want to pass a parameter from jQuery.click() method
<script type='text/javascript'>
$(window).load(function() {
$(document).ready(function() {
$('table tr').each(function() {
if ($(this).find('td').eq(6).text() === 'Start') {
$(this).css('background', 'yellow');
$(this).addClass('Start_Point');
$(this).click(a);
}
});
});
});
function a()
{
alert();
}
</script>
I want send this object to my method using .click .. 我想使用.click将这个对象发送到我的方法中。
I am already do following bt its not work . 我已经在追随它的不工作了。 the method a() is calling when the function match case for 'start' which is wrong i want when user click on table the function a() will call
当函数'start'匹配大小写时,方法a()正在调用,这是错误的,我希望当用户单击表时函数a()将调用
<script type='text/javascript'>
$(window).load(function() {
$(document).ready(function() {
$('table tr').each(function() {
if ($(this).find('td').eq(6).text() === 'Start') {
$(this).css('background', 'yellow');
$(this).addClass('Start_Point');
$(this).click(a(this));//This
}
});
});
});
function a()
{
alert();
}
</script>
You can pass an anonymous callback function as the click handler which will call the method a
with desired parameters 您可以传递一个匿名回调函数作为单击处理程序,它将使用所需参数调用方法
a
$(this).click(function(){
a(this)
});
try this 尝试这个
$(function(){
$(this).click(function(){
a(this)
});
})
then u can try 那你可以尝试
$('.Start_Point').click(function(){
a(this)
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.