You are viewing limited content. For full access, please sign in.

Question

Question

Classname matching

asked on November 15, 2019

Hi all,

 

In my form, I would like to identify all element with a specific classname (start with and contain).

 

E.g : Start with "customer_" and contains "m"

Element

<e class="form customer_emeraude" />

<e class="form customer_saphir" />

 

Jquery => Hide class "customer_*m*"

return => <e class="form customer_saphir" />

 

I tried :

Field27 = "m"

$("[class*="+$("#Field27").val()+"]").show();

But it return me all the element because of the classname "form".

 

Next, I tried  :

$("[class^=customer_]:contains("+$("#Field27").val()+")").show();

But unsuccess

 

Do you have any idea ?

 

Thanks in advance.

Regards

0 0

Replies

replied on November 18, 2019

I don't think you can do that with just css selectors. You can do "class name starts with" and "class name contains", but as in your last example they won't combine the way you want, and there is no "class name matches this pattern". You might have to choose better class names or use multiple classes. https://css-tricks.com/attribute-selectors/ is a helpful resource.

1 0
replied on November 15, 2019

Have you tried hiding before showing?

$(".form").hide();
$("[class*="+$("#Field27").val()+"]").show();

 

0 0
replied on November 18, 2019

Hi Michael, thanks for the help.

The action (Showing or hiding) is not the problem. The problème is the selection.

 

In my collection, I wish to select all element with :

1. Start with "customer_"

AND

2. contain "m"

(all restrictions for the same class' name).

 

This should be return me : <e class="form customer_emeraude" />

 

The worries is about the fonction. It looks like the AND restrictions is not for the same class' name.

 

E.G:

<e class="form customer_emeraude" /> (start with "customer_m" and get "m")

<e class="form customer_saphir" /> (start with "customer_m" and get "m" but not in the same name)

0 0
replied on November 18, 2019

Hi Brian.

 

Thanks for the tips. I changed the direction.

I added a "Title" for each div in my collection. Laserfiche don't use "title" by default so I could search only my terms.

 

Thanks for your help.

Regards

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.