1

我想发送href值。但它不工作。

function display () {
$.fancybox({
'href': 'index.php',
'width'    : '75%',
'height'   : '75%',
'autoScale'   : false,
'transitionIn'  : 'none',
'transitionOut'  : 'none',
'type'    : 'iframe'

 });

}

我试过这个:

function display (who) {
$.fancybox({
'href': 'index.php'+who,
'width'    : '75%',
'height'   : '75%',
'autoScale'   : false,
'transitionIn'  : 'none',
'transitionOut'  : 'none',
'type'    : 'iframe'

 });
}

<a onclick="javascript:display("?id=11");" href="#"  >create</a>

innerhtml 内的这个 onclick 事件,所以它不能与 ' 斜杠一起使用

为什么

4

1 回答 1

3

您可以为此使用单引号,如下所示:

<a onclick="javascript:display('?id=11');" href="#">create</a>

然而,一个更好的方法是点击处理程序,如果你给你的锚一个类,像这样:

<a class="create" href="#">create</a>

你可以像这样使用它:

$(".create").click(function() {
  display("?id=11");
});
于 2010-04-27T01:34:27.393 回答