Question

I link to the different section on the same page using anchor tag, each time it appends the id to end of url,i don't want id name to the end of url, my code look like this-

<div id="parallax-bg4">
    <a ="#"><img id="bg4-1" src="{{ STATIC_URL }}assets/images/parallax/signup.png"></a>
</div>

I write the anchor tag on id="b4-1"

<a name="bg4-1"></a>

And write the jQuery on same id for focusing the input text box.

$(function(){
    $("#bg4-1").click(function(event){
    event.preventDefault();
    $('#id_email').focus();
  });
});

Some time it works,but most of the time i need to double click on image.i also remove the event.preventDefault() but it still not work.

Was it helpful?

Solution

Try

$('a[name=bg4-1]').click(function () {});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top