Click here to Skip to main content
15,895,813 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried to create a very very simple implementation of jQuery.
please check out following code.Why it doesn't work?
Try code at here.
HTML:
HTML
<p id="a">Hello</p>

JavaScript:
JavaScript
function $(selector)
{  
    var x=new aQuery(selector);
    return x;
}

function aQuery(id)
{
    this.objId=id;
    function html(newh)
    {
        document.getElementById(this.objId).innerHTML=newh;
    }
}



$("a").html("Hello aQuery");
Posted
Updated 21-Aug-14 5:39am
v3
Comments
OriginalGriff 21-Aug-14 11:39am    
No.
I'm not going off to a random site to "try something that doesn't work". I have no idea what I will find at the other end!

If you want us to help you, then:
1) Tell us about the problem. What should it do? What does it do? How do you make it do that?
2) Show us the relevant code fragment - just the bit we need, not the whole thing - so we can see it easily.

Help us to help you!
Use the "Improve question" widget to edit your question and provide better information.
AmiR1999 21-Aug-14 11:42am    
I edited the question.Why are you so strict and angrY my friend? :D
OriginalGriff 21-Aug-14 11:53am    
That's not strict or angry: it's just explaining that you need to think about the people you are asking for help, and make it as easy for them as possible.
AmiR1999 22-Aug-14 7:55am    
I'm sorry,thank you.
OriginalGriff 22-Aug-14 8:05am    
That's OK! :laugh:

1 solution

You should create the html function inside aQuery like this:
JavaScript
this.html = function(newh)
{
    document.getElementById(this.objId).innerHTML=newh;
}
 
Share this answer
 
Comments
AmiR1999 21-Aug-14 11:45am    
Thank you. Perfect!
Thomas Daniels 21-Aug-14 11:48am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900