Sure you can. You just need to add quotes.
function test(test1) {
console.log(typeof test1);
}
document.write("<input type="button" value="Click" id='j' onclick='test(\"abc\")'/>");
More Related Contents:
- How can I do string interpolation in JavaScript?
- What is the difference between the `=` and `==` operators and what is `===`? (Single, double, and triple equals)
- How do I check that a number is float or integer?
- Where does npm install packages?
- How to make exe files from a node.js app?
- ie8 var w= window.open() – “Message: Invalid argument.”
- When do I use parentheses and when do I not?
- Handling errors in express async middleware
- Prevent form submission with enter key
- Server Side Calculation using Firebase
- Download Canvas as PNG in fabric.js giving network Error
- What events does an fire when its value is changed?
- Discord.js Bot Welcomes Member, Assign a Role and send them a DM
- What’s the difference between putting script in head and body?
- Binding vs Arrow-function (in JavaScript, or for react onClick)
- Calculate working days between two dates in Javascript excepts holidays
- Javascript: best Singleton pattern [duplicate]
- How to open specific tab of bootstrap nav tabs on click of a particuler link using jQuery?
- Can’t resolve module (not found) in React.js
- Highcharts percentage of total for simple bar chart
- (*SKIP)(*FAIL) workaround in JavaScript RegExp
- The collection nested inside firebase collection’s model doesn’t have add function
- Convert JavaScript String to be all lowercase
- JS checking deep object property existence [duplicate]
- How to create a custom input type?
- How can I dynamically highlight strings on a web page?
- How is AngularJS different from jQuery
- Why do these two javascript 2d-arrays behave differently?
- What are the key differences between JavaScript and ActionScript 3?
- Using a for each loop on an empty array in JavaScript [duplicate]