html - jquery - p element wont show after I hid it -
im trying build website , ive ran problem. got 4 pictures , whenever want click on picture, want show text. wont show, did link console log , shows working. can me this?
thanks in advance!
css
<img class ="porfoto" title="tekstroy" id ="roy" src="img/roy.png"> <img class ="porfoto" title="tekstkinmen" id ="kinmen" src="img/kinmen.png"> <img class ="porfoto" title="tekstboris" id ="boris" src="img/boris.png"> <img class ="porfoto" title="tekstelse" id ="else" src="img/else.png"> <p id="tekstroy">hallo </p> <p id="tekstkinmen">hallo2<p> <p id="tekstboris">hallo3</p> <p id="tekstelse">hallo4</p>
js
$("#tekstroy").hide(); $("#tekstkinmen").hide(); $("#tekstboris").hide(); $("#tekstelse").hide(); $(".porfoto").click(function(){ var url = $(this).attr("title"); console.log(url) $(url).show(); }); $("porfoto").click(function(){ var url = $(this).attr("title"); console.log(url) $(url).hide(); });
you close:
$(function(){ $("#tekstroy").hide(); $("#tekstkinmen").hide(); $("#tekstboris").hide(); $("#tekstelse").hide(); }); $("img").click(function(){ var url = $(this).attr("title"); $("p").hide(); $("#"+url).show(); });
Comments
Post a Comment