Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think i understand what you're trying to do.</p> <p>The reason why it does not work is because when you click the links it will then as normal send the user to whatever that's inside the href. Looks like what you're looking for is a method of having the links change dynamically depending on which page you're on? Right?</p> <p>I would suggest using a server side language to handle that. Using parameters to control what link to show.</p> <p>For an example:</p> <pre><code>&lt;ul id="searchTabs"&gt; &lt;li class="current" &gt; &lt;a rel="nofollow" href="products.php" id="product"&gt;Sản phẩm&lt;/a&gt; &lt;/li&gt; &lt;li class="tabRight"&gt; &lt;a rel="nofollow" href="products.php?os=offer" id="seller"&gt;Cung&lt;/a&gt; &lt;/li&gt; &lt;li &gt; &lt;a rel="nofollow" href="products.php?os=seeking" id="buy"&gt;Cầu&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Would become:</p> <pre><code>&lt;ul id="searchTabs"&gt; &lt;li class="current" &gt; &lt;a rel="nofollow" href="products.php?links=1" id="product"&gt;Sản phẩm&lt;/a&gt; &lt;/li&gt; &lt;li class="tabRight"&gt; &lt;a rel="nofollow" href="products.php?links=2" id="seller"&gt;Cung&lt;/a&gt; &lt;/li&gt; &lt;li &gt; &lt;a rel="nofollow" href="products.php?links=3" id="buy"&gt;Cầu&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Then you could with a server side language such as PHP do a switch on the link parameter. Then depending on what is set change the href attributes.</p> <p>-</p> <p>Reason why yours isn't working is because it redirect the user. Which means you're JavaScript won't matter at all as none of it have any influence on the other page.</p> <p>You could prevent it from changing the actual location but it does not sound like that's what you're looking for. But just in case.. In order to prevent such event you can use:</p> <pre><code>$(window).load(function(){ $("#product").click(function(e){ e.preventDefault(); $('#product').attr('href','javascript:void(0);'); $('#seller').attr('href','http://www.vmarket.com.vn/products.php?os=offer'); $('#buy').attr('href','http://www.vmarket.com.vn/products.php?os=seeking'); }); $("#seller").click(function(e) { e.preventDefault(); $('#product').attr('href','http://www.vmarket.com.vn/products.php'); $('#seller').attr('href','javascript:void(0);'); $('#buy').attr('href','http://www.vmarket.com.vn/products.php?os=seeking'); }); $("#buy").click(function() { e.preventDefault(); $('#product').attr('href','http://www.vmarket.com.vn/products.php'); $('#seller').attr('href','http://www.vmarket.com.vn/products.php?os=offer'); $('#buy').attr('href','javascript:void(0);'); }); }); </code></pre> <p>Hope that helps :) Leave a comment if there is anything you would like to explained.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload