Jump to content

Is it must to set fetchattribute() before use any fetch method in dom way


apysan

Recommended Posts

I am a new learner of php.

After going though several articles and tutorial i decide to do it in PDO way.

I execute my code without any problem without using set fetchattribute method, then why should i use it.

 

Please help to understand

Edited by apysan
Link to comment
Share on other sites

Edit: This is a Javascript-related post. If you're using PHP to output HTML, don't worry about the DOM, just print out the HTML. If you're reading an XML document, use PHP's DOMDocument object.

 

Do you mean getAttribute()?

 

In the HTML DOM, most elements have properties that are associated with the attribute. For example, an <a> element with an href attribute will have an href property. But the attribute and the property are not the same thing, the property is what actually does the work, while the attribute is just part of the DOM structure.

 

For example, if your HTML is like this:

<a id="home-link" href="/index.html">Home</a>

Then this is what the following code would be like:

alert( document.getElementById("home-link").href );                // Shows "http://www.example.com/index.html"alert( document.getElementById("home-link").getAttribute("href")); // Shows "/index.html"

In most cases, changing the attribute won't actually change the functionality of the element, you need to change the property to make it behave differently.

 

If you're working with XML DOM, none of the elements have properties, only attributes, so you must use getAttribute() and setAttribute() to work with them. I think this also holds true for XML-based technologies, such as SVG.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...