0
My script is not working, I just want to make the script display the paragraph when select is selected, see:
$(document).ready(function()
{
$("#btn1").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script>
<p>This is a paragraph.</p>
<button id="btn1">Hide</button>
<select name="categoria" id="categoria">
<option value="other">Other</option>
<option value="show" id="show">Show</option>
</select>
Why does it have 3 equal signs there? this.value === "show".
– user122195
@Davidcesar there is no need in this case, but the three equal signs mean that you are checking the value and if it is of the same type. It is that in PHP and Javascript, there is difference between
1 == '1'
and1 === '1'
, both return different things. There is a question on the website about this.– Wallace Maxters
You can explain this line to me: this.value === "show" && $("p"). show(); Vc used logical operators, I don’t understand.
– user122195
@Davidcesar in Javascript, if the
this.value === "show"
is assessed astrue
, it passes to the next expression after&&
, which is the$("p").show()
– Wallace Maxters