William Luis

0 %
William Luis
Fullstack Developer
  • Cidade:
    Santa Bárbara D'Oeste - SP
  • Idade:
    36
English
HTML
CSS
Js
PHP
WordPress
Vue
Java
jQuery
MySQL
SQL Server
Postgresql
  • Bootstrap, Materialize
  • Stylus, Sass, Less
  • Spring boot
  • Vegas, Premiere
  • Photoshop, Illustrator
  • Zbrush, Cinema 4D

Pegar informações dentro de uma TAG com Javascript

12 de dezembro de 2012

O código abaixo mostra como selecionar o valor de uma Tag, com javascript. O exemplo abaixo utiliza-se da tag span

Valor do Span aquiou
[sourcecode language="javascript"]
alert(document.getElementById('creditototal').firstChild.data);
[/sourcecode]
ou
[sourcecode language="javascript"]
alert(document.getElementById('creditototal').innerHTML);
[/sourcecode]
Outro exemplo:
[sourcecode language="javascript"]
function mostra(){
var altura = document.getElementById("img").height;
var largura = document.getElementById("img").width;
alert("Altura: "+altura+"nLargura: "+largura);
}
window.onload = mostra;
[/sourcecode]

Posted in Dicas, JavaScriptTags:
Write a comment