Reputation: 2198
This is my html code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jquery-1.9.1.min.js"></script>
</head>
<body>
<form action=" " method="post">
<input id="myInput" type="text"/>
<input id="myButton" type="button" value="submit"/>
<p id="myOutput" style="color: yellow; background: black; width: 100px;"></p>
</form>
<script>
$("#myButton").click(function() {
var data = $("#myInput").val();
$("#myOutput").val(data);
});
</script>
</body>
Let's say at the moment my code is
<p id="myOutput" style="color: yellow; background: black; width: 100px;"></p>
Is jQuery able to change the codes?
let's say if somehow I type red then the code would be
<p id="myOutput" style="color: red; background: black; width: 100px;"></p>
and if I have another input text area and input 200 then the code would be
<p id="myOutput" style="color: yellow; background: black; width: 200px;"></p>
something like that.
Not exactly want to change just the class or just the style or the width but just wondering if I can use a text area input and after submitting then maybe the value of the code would change something like that...
Upvotes: 0
Views: 195
Reputation: 160
Yes, you mainly can manipulate all your HTML Code with JQuery.
For Setting a value
$( '#myOutput' ).css( "color", "red" );
For getting a value
$( '#myOutput' ).css( "color");
Upvotes: 2