我有这个,它工作正常:
$(document).ready(
highlightTableRow
);
Run Code Online (Sandbox Code Playgroud)
但是当我添加第二个函数(见下文)时,第二个函数不起作用.
$(document).ready(
highlightTableRow,
attachClickLinkHandlerForRowLink
);
Run Code Online (Sandbox Code Playgroud)
将第二个函数添加到ready函数的correnct语法是什么?谢谢.
编辑:添加语法错误.(日食)
$(document).ready(
highlightTableRow(); **// error:Syntax error, insert ")" to complete Arguments**
attachClickHandlerForRowLink(); **//error: Missing semicolon**
); **// error: Syntax error on token ")", delete this token**
var originalRowBackground;
function highlightTableRow(){
$('[class^="contentRow"]:has(a)').live('mouseenter', enterRowFunction).live('mouseleave', exitRowFunction);
}
function enterRowFunction(){
originalRowBackground = $(this).css('background-color');
$(this).css({'background-color': "#EFE3FF", 'cursor': 'pointer'});
}
function exitRowFunction(){
$(this).css({'background-color': originalRowBackground, 'cursor': 'pointer'});
}
function attachClickHandlerForRowLink(){
$('[class^="contentRow"]:has(a)').live('click', clickRowLink);
}
function clickRowLink(){
window.location = $(this).find("a").attr("href");
} **//error: Missing semicolon**
Run Code Online (Sandbox Code Playgroud)
你能做到的
$(document).ready(function() {
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Run Code Online (Sandbox Code Playgroud)
你也可以将$(document).ready()部分改成$(function()你想要的
$(function() {
highlightTableRow();
attachClickLinkHandlerForRowLink();
});
Run Code Online (Sandbox Code Playgroud)
同样只是更短
| 归档时间: |
|
| 查看次数: |
182 次 |
| 最近记录: |