Friday 15 June 2012

jquery - Click on a tags with hrefs don't redirect me -


So now I have got a small script in JQuery which allows me to have a brief menu. My problem is that when I have this script on my page and click on one of the sub-titles, I am not redirected to the new page (i.e. if i am about the current page and i Clicking, I've been sent back to the top of the page instead) I'm not sure how my script affects a tag and href.

JS:

  $ (document) .ready (function () {$ (". Subheader"). Hide (); $ ("expand"). Click (function () {if ($ (this) .text () == "+") {$ (this) .text ("-");} and {$ (this) .text ("+") ;} $ (This) .Parent (). Next ("Subheader") SlideToggle (500);});});   

HTML:

  & lt; Div & gt; & Lt; H3 class = "title" & gt; & Lt; A href = "about /" & gt; About & lt; / A & gt; & Lt; Span class = "expansion" & gt; + & Lt; / Span & gt; & Lt; / H3 & gt; & Lt; Ul class = "subheader" & gt; & Lt; Li & gt; & Lt; A href = "about /" & gt; About 1 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "about /" & gt; About 2 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "about /" & gt; About 3 & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; H3 class = "heading" & gt; & Lt; An id = "contact" href = "contact" & gt; Contact information & lt; / A & gt; & Lt; Span class = "expansion" & gt; + & Lt; / Span & gt; & Lt; / H3 & gt; & Lt; Ul class = "subheader" & gt; & Lt; Li & gt; & Lt; A href = "contact" & gt; Contact 1 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "contact" & gt; Contact 2 & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "contact" & gt; Contact 3 & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;    

I came to know why no one from my href was redirecting me It was because of this one line it was. After removing it, all my hrefs were working again. So if there is any obstruction to this problem in the future, make sure you see which scripts are in your HTML file and look for duplicate lines because they can break your link (or not) For example, at least works.

  & lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>    

No comments:

Post a Comment