What should I do so that when a user selects a text on my page, it comes out in another color instead of the normal color (blue and white letters)?
I want to make a java program to replace spaces with % 20
. I was thinking of making a loop and when I find a " "
replacement the character with the three characters. However I have a problem with .charAt()
. Indeed it seems that you can not change a character. Here is the error:
replaceSpaces.java:8: error: unexpected type
s.charAt(i)="%20";
^
required: variable
found: value
Here is the entire program:
public class replaceSpaces{
String s = "Hello Antoine";
public static void replaceSpaces(String s){
for(int i = 0;i<s.length();i++){
if(s.charAt(i)==' '){
s.charAt(i)="%20";
}
}
System.out.println(s);
}
}
I would like to know how I can count the elements that there are with the same class in an HTML to be able to be with JQuery but with JavaScript it is also worth it.
Thank you!
Example
div class="hola"
div class="hola"
div class="hola"
A script that says there are 3 elements with class "hello".
I've tried?
var divs = document.getElementsByClassName("orange");
var numDivs = divs.length;
var contadorNaranja = 0;
for(var i = 0; i < numDivs; i++){
if(divs[i].className == "orange")
contadorNaranja++;
}
var puntos1 = contadorNaranja;
document.getElementById("jugador1puntos").innerHTML = "Jugador1: "+puntos1;
I am building a small library of floating notifications on the page and the problem arose, since on the page where I will use it there are various floating elements such as modals and buttons from third-party plugins.
A first solution would be to use a high value so z-index
let's say:
.floating-notification {
z-index: 10000;
}
But the problem is that being a fixed number does not assure me that it is the largest, since someone in a third-party library may have thought of a larger number, let's say 10001 , so if both components are shown together, the one created will be shown below.
Another forced solution would be to use the maximum admissible value for z-index
but this varies according to the browser and is not standard.
The question is if there is any way to know of all the elements of the DOM which is the maximum value of the z-index attribute.
My question is simple, I would like to know if there is any way to fill the property content
with the content of the element in question. Here is an example:
.saludo::before {
content: same; /*Sé que este valor no existe, lo he puesto para que os hagais una idea de lo que busco*/
color: green;
}
<span class="saludo">Hola</span>
Obviously I'm asking this because in the situation that I require it I wouldn't want to do a simple drop shadow of the text.
The effect I would like to achieve would be something like this .
And I also don't want to have to write the content of the element by hand ( content: "Hola"
), to make it dynamic.
Thanks in advance.