Skip to main content

Blog

jQuery - Changing Element Content

In our several previous jQuery examples we were focused to accessing DOM elements and getting their content. In this article we're going to show you how actually to change a element's content.

Below is a part of a HTML page that contains div with id = "testdiv" and a couple of other elements placed inside it:

<div id="testdiv">
    jQuery example
</div>

For changing content we can use a couple of jQuery functions:

.text(TEXT) - for setting plain text

jQuery - Getting Element's Content

We continue with our little jQuery Tips and Tricks school. In this article we'll show how to get HTML content of particular DOM element inside a HTML page.

Let's assume that there is the div with id "testdiv" and with content as follows:

<div id="testdiv">
    This is content inside testdiv.
</div>

The next jQuery code will obtain the html code for particular element, in this case for div "testdiv"

jQuery - Passing Through Elements

The next tutorial in our jQuery Tips and Tricks school is about accessing children elements of a DOM node.

C# - Check If String Is Double

Here is a code snippet for checking if string is double in C#.

jQuery - Delaying JavaScript Execution

One of the problem that could arise with our previous jQuery tutorial is that the javascript line will be executed before any of HTML DOM elements are created. So the code will try to access the DOM element that doesn't exist yet.

The only way to solve the issue is to delay the JavaScript execution untill all DOM elements are created on the page.

We can achieve this goal using $(document).ready() function after the DOM elements are loaded and ready as in the code below: