Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Tips
 

DOM HTML Attributes

 

Adding HTML in an Ajax based application is one of the smart moves a developer would have in building a lightweight online application. By using HTML, developers are harnessing the best the HTML would provide – a lightweight source of data with simplified functions that could be easily called. The familiarity of HTML is present in almost every developer that adding HTML is no problem at all.


JavaScript takes this familiarity a bit further by providing developers the ability to manipulate the attributes in HTML. By doing so, developers would have more power in controlling HTML according to their preferences. This could be done in DOM wherein developers would have more control on their JavaScript function and will not be restricted by browser limitations.


There are three ways of controlling HTML within DOM: getAttribute, setAttribute and removeAttribute. These functions have their respective advantage and disadvantages that could be considered by any developer.


The getAttribute Function

This function is highly recommended for developers who wanted to display more information from the data extracted in HTML. Through getAttribute function, developers will be able to extract the attribute and use it depending on the preferences of the developer. The attribute could be used to trigger more functions or could be used as a data for more JavaScript interaction.


When performing this function, it is often advised to target a single HTML file instead of a webpage. By doing this, the specific data is extracted and the attribute could be located faster.


The setAttribute Function

This function could be used by developers who wanted to make some changes on the attributes on data from HTML. This is one of the most powerful features of JavaScript since it can manipulate the attributes before they are launched in the client side.


But control to HTML attributes is very easy when they are done in JavaScript. After targeting the data needed, developers would just have to add the said function and along with it, the needed changes of developers. The changes could be as simple as changing the file name so that it could synch with the JavaScript coding.


The removeAttribute Function

This function is a new one but a very effective tool for developers. As the name suggests, this function helps developers remove any attribute that could be found in the filename. This is done by developers who wanted to have a lightweight Ajax or JavaScript application.


Instead of manipulating data that could show up in the client side, developers have the option of completely removing the attributes to ensure the application will work as planned without any additional functions. By removing the attributes, developers could provide a straightforward function in the application. However, this might be a little bit risky especially if the developer is not familiar with the attributes that will work with the function.


These are the three HTML attributes that could be used in DOM. Through effective usage of these functions, developers should be able to harness HTML in JavaScript and Ajax based applications without any problems.



Read Next: Using ProcessingInstruction for Ajax



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links