Posts

Showing posts with the label attribute

javascript : Object .isString

  javascript : Object  .isString Target: Applicable with any javascript  Object  Variable  that holds string value . Description : When an object holds an string value then it return  true   otherwise  undefined   . basically it is defined in String prototype. Many time in programming we face a problem that an object variable holds String value or other object structure then it help us. Before writing the code of String manipulation we can check whether a variable holds String value or not. Note: It is an property of String, that is defined in String Prototype. It is useful to check an object variable is String or any other type. another way to check variable holds string value is "typeof(variable) == 'string'" Syntax: ObjectVariable  .isString return  true  when object hold's String value otherwise  undefined Usase: var obj = 'abcd'; console.log('typeof obj = ' + typeof(obj)); if(obj.isString){      co...

javascript domElement .attr(attributeName,[attributeValue])

  javascript domElement .attr( attributeName,[attributeValue] ) Target: Get/Set DOM element attribute. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll In case of DOM NodeList first Node Element is processed for get and set to all elements. Description : get/set attribute of DOM element. if attributeValue is passed then it set the attribute and return element itself, otherwise return attribute of element. If attributeValue is blank string then it remove attribute. Note: after setting the attribute of DOM elements it return the element/elementList. Syntax: DOMElement.attr( 'attributeName',[attributeValue] ) DOMNodeList.attr( 'attributeName',[attributeValue] ) HTMLCollection.attr( 'attributeName',[attributeValue] ) Usase: document.getElementById('txtName').attr("maxlength",10) it sets the maxlength of textbox with 10 character and return textbox element document.getElementById('txtNam...

javascript : domElement.getComputedStyle()

  javascript : domElement.getComputedStyle() Target: Applicable with any DOM Element. getElementById getElementsByTagName getElementsByClassName getElementsByName querySelector querySelectorAll select etc. In case of DOM NodeList first Node Element is processed for getComputedStyle. Description : This extension method is exactly window.getComputedStyle(domElement). It return list of all style attribute applicable to that domElement. Note: when list of element passed then it reutrn first element's style attribute list. Syntax: DOMElement.getComputedStyle() DOMNodeList.getComputedStyle() HTMLCollection.getComputedStyle() Usase: document.getElementById('firstDiv').getComputedStyle() It return  CSSStyleDeclaration { } document.querySelector('#firstDiv').getComputedStyle() It return  CSSStyleDeclaration { } document.querySelectorAll('ul').getComputedStyle() It return  CSSStyleDeclaration { } document.body.getComputedStyle().width It return  "1366px" do...