Basically all I want to do is set the text of a paragraph using JavaScript/jQuery on page load. This is for a simple Kendo UI app.
Can anyone please give me a method of doing this?
I know this is probably a noob question, but I'm semi inexperienced with JavaScript/jQuery.
This is what I've already tried, but it doesn't seem to be working...
<script type=""> $(document).ready(function () { $("#mac001OEE").val("0%"); });
This code has been placed in the head of the HTML page.
Thanks :)
Assuming you are trying to set the text of a p element, use text() : $("#mac001OEE"). text("0%"); val() is used on elements which have a value attribute, such as input , select and textarea .
jQuery text() MethodThe text() method sets or returns the text content of the selected elements. When this method is used to return content, it returns the text content of all matched elements (HTML markup will be removed).
To change the text in a paragraph using JavaScript, get reference to the paragraph element, and assign new text as string value to the innerHTML property of the paragraph element.
Please try .text()
good read here: http://api.jquery.com/text/
demo http://jsfiddle.net/FyVzF/13/ or for your specific example using id please see here http://jsfiddle.net/FyVzF/14/
hope this helps!
code
$(document).ready(function() { $("p").text('test test Rambo'); });
HTML
<p> </p>
Try this only for a particular paragraph with the id "idname":
$(document).ready(function() { $("p#idname").text('test test Rambo'); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With