Jump to content

Javascript - Jquery Question


harshpandya
 Share

Recommended Posts

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

Why the mixed-up aprostophes and quotation marks?

function something(fp_id){$("#" + fp_id).show("slow");}

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...