2
Fala ae personal,
I need to get all the values href and src of the tags, link, a, img and script, so I developed the following code:
<html>
<script>
$(document).ready(function() {
function execute(){
var conteudo = $('#insert').val();
$('#processado').html(conteudo);
var links = $('#processado a[href],#processado link[href],#processado script[src],#processado img[data-src]');
$.each(links, function(index, item){
var caminho = $(item).attr('href') || $(item).attr('src') || $(item).attr('data-src') || 'Nothing';
caminho = $(item).prop('tagName') + ":" + caminho;
$.parseHTML($('#result').append(caminho + "<br>"));
});
}
$('#execute').click(function(){
execute();
});
});
</script>
<textarea id="insert" style="width:600px; height:80%;"></textarea>
<input id="execute" name="execute" type="submit" value="Execute">
<div id="processado" class="teste" style="display:none;">
</div>
<div id="result"><b>RESULTADO:</b><br>
</div>
Javascript works perfectly, however, when I copy a source code into the text-area and run the script, nothing happens.
Can someone help me with that?
From now on, very orbigado.
What a complicated path, huh. It’s not easier to set everything on one
data-src
in all and then filter through them?– Wallace Maxters