0

I am trying to bind a click event to a div which contains a input button. What i want is when the button is clicked i want to call another function.

The HTML div class is shown below.

var searchAttachPoint= document.querySelector('.header1');

And in my javascript i have these lines.

var searchAttachPoint= document.querySelector('.header1');
$(#header1).bind("click",searchPrompt("Key the text and press Ok", false));

I am getting an error saying "Unexpected token ILLEGAL " in the line where i bing the click event. Could someone please help me out. Thanks in advance.

1
  • Just in case fixing this causes another problem, searchPrompt will need to return a function for this to work Commented Mar 27, 2013 at 23:45

2 Answers 2

3

$(#header1) should be $('#header1')

Sign up to request clarification or add additional context in comments.

Comments

1

I'm quite positive you want to do:

$("#header1").bind('click', function () {
    searchPrompt("Key the text and press Ok", false);
});

You should also use .on over .bind if it's available.

You also don't use the searchAttachPoint from your example. Note that .header1 and #header are different, so maybe you even mean to do $(searchAttachPoint).bind, but that's not necessary when $(".header1") would work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.