How to select elements based on .data({key: value})

In HTML I have a div with various data- attribute properties set within a JSON object, e.g.:

<div data-layout='{
      "type" : "header",
      "minHeight" :  "10%"

In code, is it possible to select only elements which have e.g. data-layout.type==="header" without using .each or a filter function?

I'm looking for something along the lines of:



Using function from this answer, you can use pattern described below:

:data( {namespace} [{operator} {check}]  )

"operator" and "check" are optional. So, if you only have :data(a.b.c) it will simply check for the truthiness of a.b.c.

Read more about it here.

If you do not use header anywhere else in the data-layout attribute you can use the attribute contains selector like this:

$('*[data-layout *="header"]')

Need Your Help

Nesting async/await calls in ASP.NET MVC

c# asynchronous async-await

I am pretty new to async/await for ASP.NET MVC and have a quick question about it. My question is it necessary to use async/await on nested calls to a database? For instance: