jQuery - Set Content and Attributes
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#btn1").click(function(){
$("#test1").text("Hello world!");
});
$("#btn2").click(function(){
$("#test2").html("<b>Hello world!</b>");
});
$("#btn3").click(function(){
$("#test3").val("Dolly Duck");
});
});
</script>
</head>
<body>
<p id="test1">This is a paragraph.</p>
<p id="test2">This is another paragraph.</p>
<p>Input field: <input type="text" id="test3" value="Mickey Mouse"></p>
<button id="btn1">Set Text</button>
<button id="btn2">Set HTML</button>
<button id="btn3">Set Value</button>
</body>
</html>
Also in JavaScript:
- javascript date now
- javascript set html select value
- jquery styles
- Please update your node with version 8.11.3 or greater (but not version 10)
- handleClickoutside custom hook react
- how to send json data in fetch request body
- html select multiple selected values
- how to select second element in jquery
- change color of strike through line of text in react native
- how to lazyload angular
- i18n react meta description
- adonis migration column char
- create window electron
- get string after character javascript
- how to convert array converted to string back to array javasccript
- cannot create an instance of an abstract class httphandler angular
- angular mouseenter
- airbnb react native eslint
- puppeteer set header
- how to cut off decimals in javascript
- get screen width javascript
- express nodejs
- console.log clear screen
- js remove undefined from object