jQuery: The Write Less, Do More JavaScript Library

Why jQuery is not working on my page ?

View: New views
4 Messages — Rating Filter:   Alert me  

Why jQuery is not working on my page ?

by vmrao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is my code. I have included jQuery library.

<script>
(function($){
        $(document).ready(function(){

                $('ul.News li[id*="Story"]').each(function() {
                        alert('test');
                });
        });
});
</script>

<ul class="News">
<li id="Story1">My Stroy1</li>
<li id="Story2">My Stroy2</li>
<li id="Story3">My Stroy3</li>
<li id="Misc">Miscelaneous</li>
</ul>

Re: Why jQuery is not working on my page ?

by vmrao :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I just got rid of unnecessary '(function($){ ' and it worked.

On Nov 5, 5:17 pm, vmrao <maheshpav...@...> wrote:

> Here is my code. I have included jQuery library.
>
> <script>
> (function($){
>         $(document).ready(function(){
>
>                 $('ul.News li[id*="Story"]').each(function() {
>                         alert('test');
>                 });
>         });});
>
> </script>
>
> <ul class="News">
> <li id="Story1">My Stroy1</li>
> <li id="Story2">My Stroy2</li>
> <li id="Story3">My Stroy3</li>
> <li id="Misc">Miscelaneous</li>
> </ul>

Re: Re: Why jQuery is not working on my page ?

by Sam Doyle :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

li#Story would be more efficient

Sent from my iPhone

On 5 Nov 2009, at 22:24, vmrao <maheshpavani@...> wrote:

>
> I just got rid of unnecessary '(function($){ ' and it worked.
>
> On Nov 5, 5:17 pm, vmrao <maheshpav...@...> wrote:
>> Here is my code. I have included jQuery library.
>>
>> <script>
>> (function($){
>>         $(document).ready(function(){
>>
>>                 $('ul.News li[id*="Story"]').each(function() {
>>                         alert('test');
>>                 });
>>         });});
>>
>> </script>
>>
>> <ul class="News">
>> <li id="Story1">My Stroy1</li>
>> <li id="Story2">My Stroy2</li>
>> <li id="Story3">My Stroy3</li>
>> <li id="Misc">Miscelaneous</li>
>> </ul>

Re: Re: Why jQuery is not working on my page ?

by Richard D. Worth-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Thu, Nov 5, 2009 at 5:26 PM, Sam Doyle <sammeh.mp3@...> wrote:
li#Story would be more efficient

But it wouldn't match any elements. There are three elements that have ids starting with Story, but zero elements with #Story

- Richard
 

Sent from my iPhone


On 5 Nov 2009, at 22:24, vmrao <maheshpavani@...> wrote:


I just got rid of unnecessary '(function($){ ' and it worked.

On Nov 5, 5:17 pm, vmrao <maheshpav...@...> wrote:
Here is my code. I have included jQuery library.

<script>
(function($){
       $(document).ready(function(){

               $('ul.News li[id*="Story"]').each(function() {
                       alert('test');
               });
       });});

</script>

<ul class="News">
<li id="Story1">My Stroy1</li>
<li id="Story2">My Stroy2</li>
<li id="Story3">My Stroy3</li>
<li id="Misc">Miscelaneous</li>
</ul>