javascript - Why is it that when I load this page, the href of an <a> tag is getting called? -


I am working on a project where I am using an organization's header on my website. ORG's website has been created on asp.NET , which I do not know about, the part that is tripping me, is getting the search bar on the header to work. What I have tried, it is the following (some things are anonymous)

  $ (document) .ready (function () (/ {search icon holder & lt; a & gt; Select element (usually a magnifying glass) and set it as a variable: * / var searchIcon = $ ('# id1'); / * Set a variable equal to the prefix of the URL request: * / Var urlRequestPrefix = "http: // www. Orgname.com/search/Results.aspx?k="; / * Search & lt; Input & gt; element and set it as a variable: * / var search Input = $ ('# id2'); / * & lt; a & gt; tag If you click on the search, search icon searches for input. Originally in href = "javascript: someFunction ()" * / searchIcon.attr ('href', function) (window.location = urlRequestPrefix + searchInput.val);}) ;});  

But unfortunately, for some reason, window.location = urlRequestPrefix + searchInput.val (); The page loads when executing . Can anyone explain to me why and why help me fix this?

Set the code when the document is loaded, set it to the FindIn feature, Click on searchIcon.attr ('href', '#'). (Function () {window.location = urlRequestPrefix + searchInput.val ();});


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -