SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question too much recursion

    this code:
    Code JavaScript:
    $(document).ready(function() {    
    	$('body').click(function(evt) {       
    	 if(evt.target.nodeName === 'A' && $(evt.target).hasClass('cross-link')) {           
      		$('a[href=#2]').trigger('click');        }    });});

    given me and error of "too much recursion"

    how can i solve this?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,048
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    $('a[href=#2]').trigger('click');

    If that anchor has the class cross-link, than yes, what you have there is an infinite loop. Not sure what your trying to do, so the only thing I can recommend is remove that line. Though, that will kill all functionality entirely, if any. You would need to add a third condition to drop out a[href=#2] that element so that the trigger() isn't executed again.

  3. #3
    SitePoint Member
    Join Date
    Oct 2010
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so I need to create a conditional where if I am currently in a class "a.crosslink", then i do nothing?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •