简体   繁体   中英

Jquery and ajax open link and div

Welcome

How can I do to Jquery shown when you click the hidden div, and opened a link in a new window at the same time.

I am looking for an hour already and I can not find any project: (

Without any code samples this is the most specific I can be. Where yourElement is the id of the element you click on, and hiddenDiv is the div you want to show.

$('#yourElement').click(function(){
    $('#hiddenDiv').show();
    window.open('http://www.google.com', '_blank');
});

If what you are clicking on is a link (a tag) you could do it like this:

<a href="http://www.yoursite.com/otherLink"  id="yourId">Click here</a>

$('a#yourId').click(function(event) {
      event.preventDefault();
      event.stopPropagation();
      $('#hiddenDiv').show();
      window.open(this.href, '_blank');
 });

http://jsfiddle.net/HCAfz/

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