• 0 Vote(s) - 0 Average
  • 5
  • 4
  • 3
  • 2
  • 1
Thread Modes

Javascript and queryselector
#1
Hi,
I want to introduce dynamic behaviour using javascript in my apps page.
To do this, I use queryselector in a secured html widget to access page elements.
<script>

    $(document).ready(function()
        {
            var Elements = document.querySelectorAll("p");
            for (var i = 0; i < Elements.length; i++)
            {
                console.log(Elements[i].innerHTML);
            }
        });
</script>
This script runs correctly, and all paragraphs are listed in the console.
But if queryselector is bases on format (ex : h6) or on class name (ex : .classe) ... il does not work properly.
Can somebody help me to understand and fix this issue ?
Fabrice MARIE, proud to be a member of EV CONNECT FORUM since May 2018.

#2
(05-29-2019, 03:55 AM)Fabrice MARIE Wrote: Hi,
I want to introduce dynamic behaviour using javascript in my apps page.
To do this, I use queryselector in a secured html widget to access page elements.
<script>

    $(document).ready(function()
        {
            var Elements = document.querySelectorAll("p");
            for (var i = 0; i < Elements.length; i++)
            {
                console.log(Elements[i].innerHTML);
            }
        });
</script>
This script runs correctly, and all paragraphs are listed in the console.
But if queryselector is bases on format (ex : h6) or on class name (ex : .classe) ... il does not work properly.
Can somebody help me to understand and fix this issue ?

Hello

https://stackoverflow.com/questions/7065...javascript
document.querySelectorAll("h1, h2, h3, h4, h5, h6")

https://developer.mozilla.org/fr/docs/We...rySelector
var el = document.querySelector(".maclasse");

PABBE
ABBE Philippe, proud to be a member of EV CONNECT FORUM since Nov 2015.

#3
Thanks, Philippe, to confirm the syntax ... but if I use document.queryselectorall("h6"), il does not work properly.
I also tried jquery syntax ... same issue.
<script>
$(document).ready(function()
{
$("h6").hide();
});
</script>
Fabrice MARIE, proud to be a member of EV CONNECT FORUM since May 2018.

#4
(06-03-2019, 10:16 AM)Fabrice MARIE Wrote: Thanks, Philippe, to confirm the syntax ... but if I use document.queryselectorall("h6"), il does not work properly.
I also tried jquery syntax ... same issue.
<script>
   $(document).ready(function()
   {
       $("h6").hide();
   });
</script>

Hello,
Both syntax are workfing fine for me with Chrome console

P.ABBE
ABBE Philippe, proud to be a member of EV CONNECT FORUM since Nov 2015.






Users browsing this thread: 1 Guest(s)