kevin
kevin

Reputation: 49

How to reference a webelement that has an attribute with no value?

Given an attribute that has this type of markup:

<label r4e-toggle="" class="sm ng-scope ng-isolate-scope r4e-toggle" 
       ng-attr-disabled="{{audit.profileOptedOut || undefined}}" 
       tooltip="Opted In" 
       ng-if="audit.source.listing.correctable &amp;&amp; audit.hasListingCorrecting">
    <input type="checkbox" ng-model="audit.optedOut" ng-true-value="false"
           ng-false-value="true" ng-click="location.optOutAudit($index, audit)" 
           ng-disabled="location.optOutDisabled" 
           class="ng-pristine ng-untouched ng-valid">
       <span class="slider"></span>
</label>

how do i reference it by the "r4e-toggle" that is blank?

As it appears in Google Dev tools: element markup in dev tools

Upvotes: 2

Views: 55

Answers (1)

Gunderson
Gunderson

Reputation: 3266

Attributes are accessed the same way regardless if there is a value or not. Values can be provided to be more specific, but you just use square brackets for attribute selectors.

label[r4e-toggle]

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors

Upvotes: 1

Related Questions