I have the following
<label for="source" >SourceFolder</label>
I have a value in the javascript , filed is called eventtype. I am trying to do the following
<label for="source" >eventtype == 2 ? SourceDirectory
:SourceFolder</label>
How can i do this using ternary operator ?
CodePudding user response:
For eventtype is a js variable,you can only use if in js.Here is a demo:
<label id="myLable" for="source" >SourceFolder</label>
js:
<script>
var eventtype=2;
$(function() {
var data = eventtype == 2 ? "SourceDirectory" : "SourceFolder";
document.getElementById("myLable").innerHTML = data;
})
</script>