jQuery 发起 JavaScript 行动

jQuery initiate JavaScript action

<div class="button">                     
    <a class="testclass" href="javascript:actionx(objectId);"></a>
</div>

所以问题是如何使用 jQuery 启动 JavaScript 位,我试过:

window.location = javascript:actionx(objectId);

和其他一些类似的变体,但它们似乎不起作用。

对了,class是通用的,所有的按钮都有。唯一改变的是 objectId.

如果您尝试重定向,那么您可以试试这个:

html:

<div class="button">                     
<a class="testclass" href=" javascript:actionx(1234);">Redirect</a>
</div>

脚本:

function actionx(data){
    //rest of the code without return
    window.location="d3.php";//here your location to redirect
}