简体   繁体   English

jQuery 启动 JavaScript 动作

[英]jQuery initiate JavaScript action

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

So the question is how do I initiate JavaScript bit using jQuery, I have tried:所以问题是我如何使用 jQuery 启动 JavaScript 位,我尝试过:

window.location = javascript:actionx(objectId);

And some other similar variations, but they do not seem to work.以及其他一些类似的变体,但它们似乎不起作用。

By the way, class is universal and all the buttons have it.顺便说一下,类是通用的,所有的按钮都有。 The only thing that changes is the objectId .唯一改变的是objectId

If you are trying to redirect then you can try this:如果您正在尝试重定向,则可以尝试以下操作:

html: html:

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

script:脚本:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM