About meDashed CMS RSS
Kuragramming of beard
 
 
 /Root/Articles/

Favorite features javascript

24.10.2011 11:48:17 So in this article, I'll write about my favorite features in the programming language JavaScript.


   1.  The most used is probably. GetElementById () - finds the item with the specified id, and allows them to control the use of an example: document.getElementById ('content'). InnerHTML = '1 '
   2.  .InnerHTML and. Value return and assign the text content of the page. InnerHTML to simple elements (<b>, <div>, <span> etc) as well. Value for controls (<input>, <textarea>), and for some elements such as <select> can be used both in this case. innerHTML is responsible for the text inside the tag <select>,. value for value is selected.
   3. . GetElementsByTagName () [] returns an array of found items, unless in brackets indicate the number it will return an element with index in brackets. Example alert (document.getElementsByTagName ('div') [0]. InnerHTML)
   4. alert () - dialog warning in some programming languages ​​known as messageBox, in javascript it is mostly used for debugging or as an error message
   5. confirm () - dialog issue, confirm the operation has two buttons "yes" or "no" if the user clicks "yes" then the function returns true, otherwise false. Example: if (confirm ('Do you want to remove ?')){ alert (' Deleted ')}
   6.  . ParentNode - this amazing opportunity allows you to manage and parent, for example you have a tree menu on the site at the site and you need to highlight and reveal the point that corresponds to this page, you should be using. GetElementsByTagName through all the links in the menu, to compare themwith document.location and through. parentNode rodidelskie disclose all the elements, the example will not result in too long, may in another article
   7.  document.location, document.location.href ='', document.location.reload () - get the URL from the address bar, go to another page, refresh the page
   8. . OffsetWidth and offsetHeight can get the width and height of the element in pixels. Example: alert (document.getElementById ('content'). OffsetWidth)
   9.  Events:. Onclick () = function () {alert (this.id)}
      . Onmouseover (),. Onmouseout (),. Onmousemove (),. Onkeyup (),. Onkeydown () and others will not enumerate all, a nice point is that when an event ID of the item is returned in this and another interesting point, If at the end of the function to put return false, then for example on the link will not operate on the transition or <input> by pressing the keys in the event of the form onkey .. () will not trigger depression, all this can be used for a course ... example document.getElementById ('content'). onclick = function () {alert (this.id)}
  10.  The following are lists of possibilities are, they belong to the management styles
      . Style.display =''/ / none / block
      . Style.border = "1px dashed # F00"
      . Style.borderBottom = "2px"
      . Style.fontSize = "12px"
      Then I think it makes no sense to continue, since it corresponds to all css styles, the only difference is that the dash is replaced by the uppercase letter, since Javascript is case sensitive
  11.  Regular Expressions in Javascript is a very good opportunity for the page is an example: var expr = new RegExp ('(?:< font \ \ s [^>]*>)|(?:< font>) ',' igm '); document . getElementById (id). value = document.getElementById (id). value.replace (expr ,'');
  12. An interesting realization of the function object var func = function (){}, it lets you do pretty much pass on their function in the other as an argument, it allows you to create event handling, such as ajax, I already wrote about it in one article.
  13. . Split (). Join () is a direct analog of the function str_replace (), but in fact they alone counterparts explode () and implode () in PHP. The one who is just starting to learn javascript may have many questions, but why in this programming language, there is no function change from one text to another, she simply replaced by other functions described above, on the one hand, it is not easy, but with other smaller store and more to think. Such an asymmetric position, and with many other functions in javascript for example no. GetElementsByClass


I apologize article to be not very professional, I just wanted to express their opinions in simple words, and strictly speaking often confused in terms and concepts. This article is more oriented to those who are a little wrong questioned in google, well it is not able to articulate properly. I hope komunibud article will help in finding the desired function. I know from experience that finding the right solution, the answer can be intuitively pull out of any example or even a little ridiculous article like this! If you are not satisfied with the article then select the required area and presses CTRL + ENTER, comments on the site until I did, and strictly speaking do not really want to dilute the mud, would make important amendments to the text and indicate the author's participation correction!

Рейтинг $r-- [0] $r++

Показать коментарии (vkontakte.ru)
}