![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||||
| |||||
|
|
I do not know much javascript. I know php and Java and other things. In a project that I am on there is Javascript that I have to modify as part of an overall task. Basically, what I am asking is for someone to tell me what the following means. As an example, in the html code there is a line: li id=“MenuReview” onclick=“menuGetSubmenu(event, this);”>Review</li for a menu item that contains submenus. I assume that the "this" refers to the id of the <li>, or “MenuReview”. |
|
What does "event" refer to? It gets passed into menuGetSubmenu. |
|
The first number of lines of menuGetSubmenu are: function menuGetSubmenu(evt, menuItem) { e = evt || window.event; menuItem = menuItem || this; |
|
Next, what is "this" in the function? What is happening here? The MenuItem is obviously MenuReview in this example, |
|
Another, separate question, is that I have come across <a href="javascript:void(0);>...</a>. What does this do? |
#12
| |||||
| |||||
|
|
VK wrote: On Feb 3, 2:26 am, sheldonlg <sheldonlg> wrote: As an example, in the html code there is a line: li id="MenuReview" onclick="menuGetSubmenu(event, this);">Review</li I wouldn't use smart quotes in HTML source - can be troublesome sometimes. It is better to stick to "double quotes" for HTML attributes and 'single quotes' for Javascript strings. Easier to maintain and much lesser risk to run into nested quotes problem. They are actually double quotes in the code. What showed up here was the result of cut-and-paste processing. My coding technique is to use either single or double when it doesn't make a difference and to use single to enclose a double or double to enclose a single. |
|
I should have said "the element with the id specified in <li>, or 'MenuReview'". |
|
Is "event" some form of reserved keyword? |
|
It appears in the call sequence onclick="menuGetSubmenu(event, this);", and I don't see where it would get it from unless "event" is reserved to take on the type of event. in this case "onClick". So, where does "event" get defined? |
|
This statement leads me to believe that my supposition just above is correct and evt (which comes from event) refers to the onClick event. |
#13
| |||
| |||
|
|
VK wrote: [...] Thomas 'PointedEars' Lahn [...] wrote: So you should have simply refrained from posting about them which would have spared this newsgroup another load of your nonsense and FUD. Thomas, with however little you know about Javascript and DOM programming, [...] ROTFL. You are confusing me with someone else, probably yourself. |
![]() |
| Thread Tools | |
| Display Modes | |
| |