3
3
3vgeny2019-02-12 14:54:15
XAML
3vgeny, 2019-02-12 14:54:15

Is it possible to loop a script for another loop?

Hello.
I want to hide some content in the post loop from Internet Explorer users
If I apply this code

<div id="allbrausers" style="display: block">dddddddd</div>
    <script type="text/javascript">
    if (navigator.appName == 'Microsoft Internet Explorer') document.getElementById('allbrausers').style.display = 'none';
</script>

But this works exactly once only for the last added post. Is it possible to hide certain content in this way, such as title or permalink in all posts. Those. somehow loop this script relative to another loop?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dies Irae, 2019-02-12
@3vgeny

ID - unique identifier, i.e. they must not be repeated. It is better to assign a class to the elements.
With jQuery:

$(document).ready(function(){
  if (navigator.appName == 'Microsoft Internet Explorer')  $(".btn").hide();
});

F
FeST1Val, 2019-02-12
@FeST1Val

That is, you want to post such a script under each post?...
Just do a search of the content when loading the page... Something like this...
In general, you can make it as an option with conditional comments

<!--[if !IE]>
  <div id="allbrausers" style="display: block">dddddddd</div>
  <div id="allbrausers" style="display: block">dddddddd</div>
  <div id="allbrausers" style="display: block">dddddddd</div>
  <div id="allbrausers" style="display: block">dddddddd</div>
<![endif]-->

D
Dmitry, 2019-02-12
@dimasmagadan

it is correct to do this:
1 add the class of the current browser to the body (if a person entered with chrome, it will be like this body class="chrome ..", if with ie - body class="ie ..." and so on). how to do it for WordPRess on the internet a lot of tutorials
2 in css add .ie .noie {display:none}
3 in a loop / in any other place add the .noie class to the necessary elements
why other tips are bad:
1 making several duplicate id on the page is not valid
2 hiding elements via jquery is bad - scripts may not load immediately, blocks will be visible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question