简体   繁体   English

如何使用ahref链接引用另一个页面ID?

[英]How to reference to another page id using ahref link?

I have a page where i used to referene to another page div id and trigger click event for edit particular div form fields.我有一个页面,我曾经在其中引用另一个页面 div id 并触发单击事件以编辑特定的 div 表单字段。

Profile page个人资料页

<a href="<?php echo base_url('settings_pro/edit'); ?>" name="pull-right" class="edits editabil" id="showEdit">EDIT PROFILE</a>

Settings page设置页面

<div id="edit"></div>

$(document).ready(function(){
    if(settings_pro/edit){
        $("#edit").trigger("click");
    }
});

I am using codeigniter it redirect to error page.我正在使用 codeigniter 它重定向到错误页面。 how to achieve it in codeigniter如何在 codeigniter 中实现它

create a link with hash tag like this <?php echo base_url('settings_pro#edit'); ?>创建一个带有这样的哈希标签的链接<?php echo base_url('settings_pro#edit'); ?> <?php echo base_url('settings_pro#edit'); ?>

In jquery get the hash tag value return by url and perform the operation whatever you needs在 jquery 中获取由 url 返回的哈希标签值并执行您需要的任何操作

$(document).ready(function(){
  var hash = url.substring(url.indexOf('#')+1); // get the hash tag value
  if(hash == "edit"){
    //do whatever you needs
    $("#edit").trigger("click");
  }
});

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

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