Reputation: 69
I'm trying to use two arguments in a function, but it's not working? This is not the final function, I'm just trying to get the arguments to work.
the html:
<div id = "textButton" class = "convertButtonss" onclick = illegal_chr("bin" ,"binary")>
<p id = "textButton_p">
txt/dec
</p>
</div>
the Javascript:
function illegal_chr(name, type) {
alert(name);
alert(type);
}
when I click on the div nothing happpens?
Upvotes: 1
Views: 70
Reputation: 2049
Remember that tag attributes in HTML must be surrounded by quotes or double-quotes. Try this:
<div id = "textButton" class = "convertButtonss" onclick = 'illegal_chr("bin" ,"binary")'>
<p id = "textButton_p">
txt/dec
</p>
</div>
Upvotes: 3
Reputation: 149020
Try wrapping the entire attribute value in double quotes, and the string literals in single quotes, or vice versa, like this:
<div … onclick="illegal_chr('bin','binary')">
Upvotes: 3