nmoa Posted June 17, 2016 at 04:23 PM Report #597242 Posted June 17, 2016 at 04:23 PM (edited) boa tarde estou aqui com uma duvida em usar o each tenho uma listagem onde cada linha ao carregar irá abrir uma pagina nova, cada linha tem um atributo associado gostaria que no jquery ao carregar nessa linha ele soubesse qual o atributo tenho feito assim $(msg).each(function(){ for (var i = 0; i < this.attributes.length; i++) { console.log(' Valor:' +this.attributes["data-id"].nodeValue); var id=this.attributes["data-id"].nodeValue; }; //return false; }); só que ele assim dá-me a listagem de todos os atributos, se coloco o return false ele só me dá o primeiro atributo... sei que está a faltar alguma forma de poder tirar deste each apenas o valo clicado obrigado desde já pela ajuda Edited June 17, 2016 at 04:24 PM by nmoa
HappyHippyHippo Posted June 17, 2016 at 04:34 PM Report #597243 Posted June 17, 2016 at 04:34 PM não falta nada nesse código ? estou a dizer código que tens ai e falta aqui no post ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
nmoa Posted June 17, 2016 at 04:41 PM Author Report #597244 Posted June 17, 2016 at 04:41 PM var msgListing = $('.panel > #message-table > tbody > tr > td'); var msg= $('.panel > #message-table > tbody > tr '); msgListing.not(":first-child").on('click', function (e) { e.stopPropagation(); e.preventDefault(); $(msg).each(function(){ for (var i = 0; i < this.attributes.length; i++) { console.log(' Valor:' +this.attributes["data-id"].nodeValue); var id=this.attributes["data-id"].nodeValue; teste(id); }; //return false; }); mais completo
HappyHippyHippo Posted June 17, 2016 at 04:49 PM Report #597245 Posted June 17, 2016 at 04:49 PM msgListing.not(":first-child").on('click', function (e) { console.log('Valor: ' + $(this).attr('data-id')); return false; }); IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
nmoa Posted June 20, 2016 at 09:15 AM Author Report #597296 Posted June 20, 2016 at 09:15 AM da o erro Valor: undefined aproveito para deixar aqui o codigo php $passagem= mysql_query ("SELECT * FROM passagem limit $inicio, $qnt "); $passagem2= mysql_query ("SELECT * FROM passagem "); $total_registros = mysql_num_rows($passagem2); $pags = ceil($total_registros / $qnt); while ($passa=mysql_fetch_array($passagem)){ $emissor = mysql_query ("SELECT * from comercial where id_comercial=".$passa["id_emissor"].""); $emi = mysql_fetch_array($emissor); $comercial = mysql_query ("SELECT * from comercial where id_comercial=".$passa["id_comercial"].""); $comerc = mysql_fetch_array($comercial); echo' <tr class="message-unread" data-id="'.$passa["id_passagem"].'"> <td class="hidden-xs"> <label class="option block mn"> <input id="escolha" type="checkbox" name="mobileos" value="FR"><span class="checkbox mn"></span> </label> </td> <td>'.$emi["nome"].'</td> <td>'.$comerc["nome"].'</td> <td class="text-center fw400">'.$passa["data"].'</td> </tr> '; }
HappyHippyHippo Posted June 20, 2016 at 10:11 AM Report #597299 Posted June 20, 2016 at 10:11 AM $(document).ready(function() { $(".message-unread").click(function () { console.log('Valor: ' + $(this).attr('data-id')); return false; }); }); IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now