
Problemas con DataSet HTML5
Publicado por Victor (22 intervenciones) el 08/08/2017 10:23:18
Buenos dias.
Tengo estoy intentando acceder al getAttribute de un obleto html pero me dice el navegador que esa propiedad no existe.
Este es el codigo:
Alguna idea?
Saludos.
Tengo estoy intentando acceder al getAttribute de un obleto html pero me dice el navegador que esa propiedad no existe.
Este es el codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
var plant = document.getElementById("stranwerryPlant");
var fruitCount = plant.getAttribute("data-fruit");
console.log(fruitCount);
</script>
</head>
<body>
<div>Ejemplo1 DataSet,DataAtributes y JavaScript</div>
<ul id="vegetable-seeds">
<li data-spacing="10cm" data-sowing-time="March to June">Carrots</li>
<li data-spacing="30cm" data-sowing-time="Febrery to March">Celery</li>
<li data-spacing="3cm" data-sowing-time="March to September">Radishes</li>
</ul>
<div id="stranwerryPlant" data-fruit="12">EEeooooooo</div>
</body>
</html>
Alguna idea?
Saludos.
Valora esta pregunta


0