Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
What is the ^= operator in jQuery?

I have come across some JS/jQuery code and am trying to find out what the ^= operator means. I can't find anything like this when Googling it.

The HTML page contains a form with these input fields:

<input type="text" id="name" name="name[1]" value="" size="22"/>
<input type="text" id="name" name="name[2]" value="" size="22"/>
<input type="text" id="name" name="name[3]" value="" size="22"/>

The JS validates the form before sending it to the server. Can somebody explain to me how the jQuery selector that is used in the lines with val and each works (or point me to the documentation)?

jQuery("button#finish").click(function(e) {
  var error = false;
  e.preventDefault();
  if (jQuery("[name^=name]").val() != "" ) {
    jQuery("[name^=name]").each(function(){ 
      if (jQuery(this).val() == "") { jQuery(this).closest("tr").remove(); }
    }); 
    
    if ( ! error) { jQuery("#form_names").submit(); }
  }
  else { alert("Bitte mindestens eine Person zuoberst in das Formular eintragen."); }

  });

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The jQuery() function (and it's alias the $() function) take a CSS selector as an argument to determine which element(s) to operate on. The list of supported selectors is given in the jQuery API documentation.

Here, the selector [foo^="bar"] means:

[an] element whose "foo" attribute value begins exactly with the string "bar"

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda