-1

Possible Duplicate:
What is Unobtrusive Javascript in layman terms?

I refer a site in which they mentioned as follows

ASP.NET 4.5 includes the following new features:

  • Support for unobtrusive JavaScript in client-side validation scripts.

What does "unobtrusive JavaScript" mean?

Community
  • 1
  • 1
Earth
  • 3,477
  • 6
  • 37
  • 78

1 Answers1

1

Unobtrusive Javascript means it doesnt intefere with the markup (HTML).

E.g.

Obtrusive JS in the HTML:

<a onclick="myFunction()">My Link</a>

Unobtrusive JS:

In the HTML:

<a>My Link</a>

In the JS:

$('a').click(function() {
    //Code in here
);

Note in the unobtrusive example the JS could be entirely stored in a separate JS file.

cowls
  • 24,013
  • 8
  • 48
  • 78
  • HI cowls, i suggest you tidy the unobtrusive example. not my -1 but an example with Anchor HTML and JS together isnt ideal. js that queried the Document by id and had onclick or similar would be better dont you think ? Dont mix html and JS is the whole idea. Is there a why to highlight that separation with your example? – phil soady Dec 29 '12 at 11:25
  • thanks Cowls, btw the -1, can we see a comment with your view please ? – phil soady Dec 29 '12 at 11:32