简体   繁体   中英

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:

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 .

If you are trying to redirect then you can try this:

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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