harshpandya Posted August 20, 2009 Share Posted August 20, 2009 Hi Guys here is my code its jquery code but its simple so i thought you would help me This code works but instead of passing string i wanted to pass variable function something(fp_id){$("#fp_201").show("slow");}so i tried this but it does not work can you helpfunction something(fp_id){$('"#' + fp_id + '"').show("slow");}please help Link to comment Share on other sites More sharing options...
Synook Posted August 20, 2009 Share Posted August 20, 2009 Why the mixed-up aprostophes and quotation marks? function something(fp_id){$("#" + fp_id).show("slow");} Link to comment Share on other sites More sharing options...
harshpandya Posted August 20, 2009 Author Share Posted August 20, 2009 Thanks for your answer but now there is another problem var floorplan_id = 0; function showFloorPlan(fp_id){ floorplan_id = fp_id; $("#fp_building_h").hide("slow"); $("#first_FP_h").hide("slow"); $("#" + fp_id).show("slow"); $("#" + fp_id).width(0); $("#" + fp_id).height(0); $("#" + fp_id).animate({ width: "900px", height: "400px", display: "block", opacity: 0.9, marginLeft: "0.6in", fontSize: "3em", borderWidth: "10px" }, 900); } $(document).ready(function() { $("#" + floorplan_id).click(function(){ $(this).slideUp(); $("#fp_building_h").show("slow"); $("#first_FP_h").show("slow"); }); });This code worked but when i put this bold line in there it does not work - I assigned the id value to floorplan_id variable then why it does not recognize it - How to solve this problem, Please help, Thanks, Link to comment Share on other sites More sharing options...
Synook Posted August 20, 2009 Share Posted August 20, 2009 floorplan_id resolves to 0, which means you are trying to reference an object with id "0". You can't do that, because DOM IDs cannot start with numeric characters. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.