Docs Installation Playground Explore AST

Set on System Basis

Changing Attributes in BroCode

BroCode makes attribute manipulation as easy as ordering a pizza! Whether you need to set, get, or remove attributes, we’ve got you covered with simple and intuitive methods. Let’s dive into how you can master attribute manipulation in BroCode.


Quick Reference 🛠️

Set

Set attributes using the 'attribute' method.

BROCODE
bro ele ka attribute("name", "value") set krde;

Get

Retrieve attribute values with 'attribute' method.

BROCODE
bro ele ka attribute("name") le aa;

Remove

Remove an attribute using 'attribute' method.

BROCODE
bro ele ka attribute("name") hta de;

Some example usages ⚡

Set Attribute Example

Setting attributes is like giving your elements superpowers.

BROCODE
bro myButton ka attribute("disabled", "true") set krde;

Get Attribute Example

Need to check what value an attribute has? Use the 'get' method.

BROCODE
bro userId ka attribute("data-id") le aa;

Remove Attribute Example

Sometimes you need to clean up. Removing attributes is just as simple as setting them!

BROCODE
bro myButton ka attribute("disabled") hta de;

Practical Examples 💻

1Form Validation

Disable and enable form elements dynamically.

BROCODE
bro submitBtn ka attribute("disabled", "true") set krde;
bro submitBtn ka attribute("disabled") hta de;

2Image Loading

Set image source with loading attribute.

BROCODE
bro myImage ka attribute("src", "large-image.jpg") set krde;
bro myImage ka attribute("loading", "lazy") set krde;

Best Practices

Some helpful guidelines to work efficiently with attributes.

🎯 Always validate attribute values before setting them🎯 Use data attributes for storing custom data🎯 Remove attributes when they’re no longer needed

BroCode © 2024. All rights reserved.