Copyright © ashik rahman's Blog
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, June 9, 2013

Use of .delegate() function in Jquery

when we need to play with html which is already manipulated with jquery we have to use   .delegate() function in Jquery.

suppose you have generated some list item by an ajax call from DB. Now you've to give an event functionality by clicking those list. then .delegate() will help you a lot
$("body ul").delegate("li", "click", function(){
//add some code
alert( $(this).text() );
});


Monday, February 25, 2013

introducing user interface Javascript_&_Jquery

I think we have to know about the user experience.That means now i'm going to write about the user interface.Coding in the front-end of application known as user interface,in scripting language we have to encoded our code by < script > tag. In css we have to encode by this:
< script type="text/css">< /script >
And in javascript we have to encode by this:
< script type="text/javascript" >< /script >
Usually this kind of script works when browser load the page or depending user actions. So that it's called client side language.
Now I'm going to discuss about some basic javascript coding.
Write to the Document with JavaScript

document.write("My First JavaScript coding");
Change HTML elements with JavaScript
document.getElementById("demo").innerHTML="My First JavaScript";
Here "domo" is the id of any HTML elements.
we can also add an external script page in our main page by this way:
<script src="myScript.js"></script > 
One more thing I'm telling you that there is an alternative way to write script using Jquery. for this we need to add a script at the beginning of the root html file. also you can download this jquery file from this link: Jquery Link and set it to your local folder and embed it as like this:
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
The jQuery API has a number of hosts that have recent and up-to-date versions:
one and only theme of using Jquery is that "Do a lot write short".