0

I have an html DL list. Whenever I click on a DD, I would like to get its class name and pass it as a parameter to the Jquery .load function.

This is my code:

How do I change the .kilye class in order for it to get the class from the elementClass variable?

$('dd').click(function(){
$('#img').show();
var elementClass = $(this).attr("class");
$(this).toggleClass('active').siblings().removeClass('active');
$('.bio').load('/people/index.html .kilye', function(){
   $('#img').hide();
   $('.bio').slideToggle('slow');
   });
});
1
  • You can pass it as a parameter Commented Feb 18, 2014 at 16:34

2 Answers 2

1

A simple string concatenation:

 $('.bio').load('/people/index.html .'+ elementClass, function(){})
Sign up to request clarification or add additional context in comments.

Comments

1

Try this

   $('dd').click(function(){
    $('#img').show();
    var elementClass = $(this).attr("class");
    $(this).toggleClass('active').siblings().removeClass('active');
    var url = '/people/index.html .'+elementClass;
    $('.bio').load(url, function(){
       $('#img').hide();
       $('.bio').slideToggle('slow');
       });
    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.