简体   繁体   English

如何在jQuery中使用锚标签

[英]How to use an anchor tag with jQuery

I have a slider script that can link to other tabs in the slider using anchor tags 我有一个滑块脚本,可以使用锚标签链接到滑块中的其他选项卡

The html HTML

<a class="st_ext" href="#tab_<? echo $next_tab; ?>"
     rel="st_horizontal<? echo $audit_id; ?>">tab link</a>

This will move to the slider to the next tab. 这将移至滑块的下一个选项卡。 It works if I wrap it around the submit button but then the ajax query doesn't work). 如果我将其包装在Submit按钮周围,则它可以工作,但是ajax查询不起作用)。

Question is, how would I put this into a jquery success response? 问题是,如何将其放入jQuery成功响应中? I would like it f the user can click on the button that triggers the ajax call and if it is successful it opens the next tab on the slider using the above method. 我希望用户可以单击触发ajax调用的按钮,如果成功,它将使用上述方法打开滑块上的下一个选项卡。

The jQuery ajax jQuery Ajax

type: "POST",
url: "ajax/image_audit.php",
dataType: "json",
data: $('#audit_form'+form_id).serialize()+'&standard_used='+standard_in_sight,
    success: function(response){
         ------> call to anchor tag here
}

Alertnatively, if I can't do this is there a way that I can add the tag to the button so that the jquery is called first before the tag? 明智地,如果我不能执行此操作,则可以将标记添加到按钮,以便在标记之前先调用jquery吗?

The button.. 按钮..

    <input type="button" 
 name="audit_submit" class="audit_submit audit_submit_btn ie7_submit" value="" />

The ajax is called using the audit_submit class as the trigger 使用audit_submit类作为触发器来调用ajax

Try this $(".st_ext").click(); 试试这个$(".st_ext").click(); if you have many elements styled with st_ext add id to the anchor element and call something like below 如果您有许多使用st_ext样式设置的元素,请向锚元素添加id并调用以下内容

<a id="click_me" class="st_ext" href="#tab_<? echo $next_tab; ?>"
     rel="st_horizontal<? echo $audit_id; ?>">tab link</a>

$("#click_me").click();

hope it helps. 希望能帮助到你。

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

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