Sunday, 15 September 2013

How to convert javascript inline code to jQuery? -


I have this work jQuery + inline javascript which causes conflict with existing jQuery.

  & lt; Script & gt; Var jq = jQuery.noConflict (); Function goto (id, t) {jq ("content box-wrapper"). Animate ({"left": - (jq (id) .position (). Left)}, 600); Jq ('# slide a'). RemoveClass ('active'); JQ (t) .addClass ('active'); } & Lt; / Script & gt;   
 & lta square = "active" href = "#" onClick = "goto ('# kr', this); Return back" & gt;  
 & amp; ; Lta class = "active" href = "#" onClick = "goto ('# n', this); return back" & gt;  

(I have tried to solve the conflict as you can see but I believe that conflict with inline javascript arises.)

How do I make this inline javascript Can i change Thank you.

You can tie it to:

  & lt; Script & gt; // var jq = jQuery.noConflict (); Function goto1 (id, t) {... return false; // Wrong return to stop the default action of the link // Once your DOM is ready, and a.active is available for Bound $ (document) .ready (function () {// a. Activate all clicks on active function 'goto1' $ ('a.active'). Click (goto1);}); & Lt; / Script & gt;   

Variable names like geto can be potential causes of confusion later on. It has been changed to goto1 .

No comments:

Post a Comment