2

I am using ASP.NET to create a page with a GridView and Image , this code show in Image GridView's first row picture, how can I get next row source?

$('#Image1').src = $('#grdImages td img').src;
Sushanth --
  • 55,259
  • 9
  • 66
  • 105

1 Answers1

0

Also this syntax is wrong as a jQuery object has no method called src .. A DOM object does..

Try this instead

$('#grdImages td img')[0].src; // Plain javascript

$('#grdImages td img').attr('src'); // jQuery

If you are in the context of an event try this

$(this).closest('tr').next('tr').find('img').attr('src')

You can always select the row using eq selector

$('#grdImages).find('tr:eq(1) img').attr('src');

Selects the second row.

Sushanth --
  • 55,259
  • 9
  • 66
  • 105
  • $('#Image1').src=$('#grdImages').find('tr:eq(1) img').attr('src'); TypeError: Object # has no method 'find' – user2601121 Jul 19 '13 at 22:37
  • oops... Try this selector instead `$('[id*=grdImages]')` .. You are using `ASp.NET` server controls right.. – Sushanth -- Jul 19 '13 at 22:44
  • Try `console.log($('[id*=grdImages]').length)` and check if it is giving a length of 1 .. Also make sure you enclose you code inside `$(function() { // your code });` – Sushanth -- Jul 19 '13 at 22:52
  • Error: SyntaxError: DOM Exception 12. im using jquery first time. and i dont know where is mistake – user2601121 Jul 19 '13 at 23:03