mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
LibWeb: Add document.querySelector()
This commit is contained in:
parent
6e505b853e
commit
67b742bf32
8 changed files with 46 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
function drawSomeCurves() {
|
||||
|
||||
var canvas = document.querySelectorAll("canvas")[0];
|
||||
var canvas = document.querySelector("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
var x = 150;
|
||||
var y = 150;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
function drawHouse() {
|
||||
|
||||
var ctx = document.querySelectorAll("canvas")[0].getContext("2d");
|
||||
var ctx = document.querySelector("canvas").getContext("2d");
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillRect(0, 0, 300, 300);
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
</style>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
img = document.querySelectorAll("img")[0];
|
||||
img = document.querySelector("img");
|
||||
|
||||
img.addEventListener("load", function() {
|
||||
var ctx = document.querySelectorAll("canvas")[0].getContext("2d");
|
||||
var ctx = document.querySelector("canvas").getContext("2d");
|
||||
ctx.fillStyle = '#666';
|
||||
ctx.fillRect(0, 0, 400, 400);
|
||||
ctx.scale(2, 2);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div id="set_href">Click me to set location.href!</div>
|
||||
<div id="reload">Click me to call location.reload()!</div>
|
||||
<script>
|
||||
var pre = document.querySelectorAll("pre")[0];
|
||||
var pre = document.querySelector("pre");
|
||||
pre.innerHTML += "href: " + location.href + '\n';
|
||||
pre.innerHTML += "protocol: " + location.protocol + '\n';
|
||||
pre.innerHTML += "host: " + location.host + '\n';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue