[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread Giovanni Battista Lenoci


b u d d h a ha scritto:

hi,

i have more than 20 images in a form

which might be refering like this image src = images/search.gif/

i want a jquery script for replacing all image src with image src =
http://s.images/images/search.gif/
  
This is the code, but personally I prefer make changes like this on the 
server side.


$('img').each(function() {
 $('img').attr('src': http://s.images/+$(this).attr('src'));
});

--
gianiaz.net - web solutions
via angelo custode, 10 - 23100 sondrio (so) - italy
+39 347 7196482 



[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread Giovanni Battista Lenoci


Sorry i forgot the braces.

This is the right code:


$('img').each(function() {
 $('img').attr({'src': http://s.images/+$(this).attr('src')});
});





--
gianiaz.net - web solutions
via angelo custode, 10 - 23100 sondrio (so) - italy
+39 347 7196482 



[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread b u d d h a

i tried but not wrking
am placing a sample code which i used

 script type=text/javascript
  $(document).ready(

 $('img').each(
function()
{
$('img').attr({'src', http://localhost/
s.demo/+$(this).attr('src')});
});
);
/script

buddha

On Jan 20, 5:18 pm, Giovanni Battista Lenoci gian...@gmail.com
wrote:
 Sorry i forgot the braces.

 This is the right code:

  $('img').each(function() {
   $('img').attr({'src': http://s.images/+$(this).attr('src')});
  });

 --
 gianiaz.net - web solutions
 via angelo custode, 10 - 23100 sondrio (so) - italy
 +39 347 7196482


[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread Giovanni Battista Lenoci


b u d d h a ha scritto:

i tried but not wrking
am placing a sample code which i used

 script type=text/javascript
  $(document).ready(

 $('img').each(
function()
{
$('img').attr({'src', http://localhost/
s.demo/+$(this).attr('src')});
});
);
/script
  

Maybe I confused you.

You've mixed two types of syntax. You can achieve this with 2 syntax:

1.
$('img').each(function(){
$('img').attr({'src': http://localhost/s.demo/+$(this).attr('src')});
});

2.
$('img').each(function(){
$('img').attr('src',http://localhost/s.demo/+$(this).attr('src'));
});

In the case n.1 you are passing an object to the attr method using the 
json syntax :  {'key':'value'}  // better if you want to change several 
attributes in only one call.
In the case n.2 you are passing 2 params to the attr method : key, value 
// it's ok in your case



--
gianiaz.net - web solutions
via angelo custode, 10 - 23100 sondrio (so) - italy
+39 347 7196482 



[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread Shawn Grover


Giovanni Battista Lenoci wrote:

Maybe I confused you.

You've mixed two types of syntax. You can achieve this with 2 syntax:

1.
$('img').each(function(){
$('img').attr({'src': http://localhost/s.demo/+$(this).attr('src')});
});

2.
$('img').each(function(){
$('img').attr('src',http://localhost/s.demo/+$(this).attr('src'));
});


You have a slight issue with the samples.  The first instance of 
$('img') inside the function() should be $(this).


Shawn


[jQuery] Re: change image scr of all images in a page

2009-01-20 Thread Giovanni Battista Lenoci


Shawn Grover ha scritto:
You have a slight issue with the samples.  The first instance of 
$('img') inside the function() should be $(this).

Sorry, you're right... I've answered without the right attention :-P

Giovanni

--
gianiaz.net - web solutions
via angelo custode, 10 - 23100 sondrio (so) - italy
+39 347 7196482