Hitesh Chauhan Hitesh Chauhan - 1 year ago 102
Javascript Question

is it possible to set javascript:void(0) with #map for tabs in href?

i want to set JavaScript:void(0) with #map tabs in h ref. i want to set JavaScript:void(0) which is responsible for not to load the webpage on click. #map is tab .so i want to set both JavaScript:void(0) and #map. check here

my code is

<li><a data-toggle="tab" href="#map" href="javascript:void(0)" onclick="getvalue('+val['product_id']+');" id="maptab">map</a></li>

Answer Source

No need to use both actually you can use .preventDefault() when you write javascript function for this <a>.

$('li a').click(function(e){
  //... other code of function

.preventDefault() prevents the default function of the element. so the page load will be prevented with this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download