www.webdeveloper.com
Results 1 to 3 of 3

Thread: jquery addClass with id equal to parameter

  1. #1
    Join Date
    Apr 2010
    Posts
    22

    jquery addClass with id equal to parameter

    I am trying to set an li with a class based on a parameter from a function;

    here is my code
    Code:
    if (ISSUE_support == null) {
    	$('li #' + issue).addClass('highlight');
    }
    else if (issue != ISSUE_support) {
    	$('li #' + ISSUE_support).removeClass('highlight');
    	$('li #' + issue).addClass('highlight');
    }
    but the class is not added when the event is executed.

  2. #2
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    Your selector is saying: Find me an li that contains an element with the id equal to ~issue

    Is that what you wanted?

    Eric

  3. #3
    Join Date
    Apr 2010
    Posts
    22
    no, I want to to use the value of the variable which is equal to an id.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles