Noskiw Posted October 30, 2010 Share Posted October 30, 2010 $(document).ready(function(){ if($("#acc").length > 0){ $("dd#1").slideToggle(200); $("dt#2").addClass("act"); $("#acc dt").click(function(){ var sel = $(this); sel.addClass("act current"); $("#acc dt a:selected").css("color", "blue"); sel.parent().children("dd").each(function(){ if($(this).is(":visible") && !$(this).prev("dt").hasClass("current")){ if($(this).prev("dt").hasClass("act")){ $(this).prev("dt").removeClass("act"); } $(this).slideUp(200); } }); sel.next().slideToggle(200, function(){ if(!$(this).is(":visible")){ $(this).prev("dd").removeClass("act"); } sel.removeClass("current"); if(!$(this).is(":visible")){ if($(this).click){ sel.removeClass("act"); } } }); return false; }); } }); The main bit I'm struggling with is adding a class to the "a" tag within the "dt" tag, which is inside the "acc" div. I've tried: $("#acc dt a:selected").css("color", "blue"); I need to find a way to add a class to the selected tag Link to comment https://forums.phpfreaks.com/topic/217322-a-bit-of-jquery-help-please/ Share on other sites More sharing options...
Noskiw Posted October 30, 2010 Author Share Posted October 30, 2010 I guess you also need to see my html layout too <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>INSERT TITLE HERE!</title> <meta http-equiv="Content-type" content="text/html; charsetUFT-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <meta http-equiv="imagetoolbar" content="no" /> <link href="./css/core.css" rel="stylesheet" type="text/css" /> <script src="./js/jquery.js" type="text/javascript"></script> <script src="./js/functions.js" type="text/javascript"></script> </head> <body> <h1 style="padding: 20px;">INSERT NAME HERE!</h1> <div id="wr"> <dl id="acc"> <dt id="2"><a href="#">Home</a></dt> <dd id="1"><?php include "./inc/homes.php"; ?></dd> <dt><a href="#">Hi!</a></dt> <dd><?php include "./inc/about.php"; ?></dd> <dt><a href="#">Hi!</a></dt> <dd><?php include "./inc/mems.php"; ?></dd> <dt><a href="#">Hi!</a></dt> <dd><?php include "./inc/founded.php"; ?></dd> <dt><a href="#">Hi!</a></dt> <dd><?php include "./inc/contact.php"; ?></dd> </dl> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/217322-a-bit-of-jquery-help-please/#findComment-1128509 Share on other sites More sharing options...
Noskiw Posted November 2, 2010 Author Share Posted November 2, 2010 Please a bit of help? :/ Link to comment https://forums.phpfreaks.com/topic/217322-a-bit-of-jquery-help-please/#findComment-1129528 Share on other sites More sharing options...
michaellunsford Posted November 5, 2010 Share Posted November 5, 2010 I didn't know an <a> tag could be selected ??? you could try: $("#acc dt a").click(function() { this.css("color", "blue"); }); Link to comment https://forums.phpfreaks.com/topic/217322-a-bit-of-jquery-help-please/#findComment-1130520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.