Questions tagged [attributes]

The attributes tag should be used for any issues relating to a property of an object, element, or file, etc.

In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such.

For clarity, attributes should more correctly be considered metadata. An attribute is frequently and generally a property of a property.

However, in actual usage, the term attribute can and is often treated as equivalent to a property, depending on the technology being discussed.

An attribute of an object usually consists of a name and a value; of an element, a type or class name; of a file, a name and extension.

  • Each named attribute has an associated set of rules called operations: one doesn't sum characters or manipulate and process an integer array as an image object — one doesn't process text as type floating point (decimal numbers).
  • It follows that an object definition can be extended by imposing data typing: a representation format, a default value, and legal operations (rules) and restrictions ("Division by zero is not to be tolerated!") are all potentially involved in defining an attribute, or conversely, may be spoken of as attributes of that object's type. A JPEG file is not decoded by the same operations (however similar they may be—these are all graphics data formats) as a PNG or BMP file, nor is a floating point typed number operated upon by the rules applied to typed long integers.

See also:

13044 questions
269
votes
5 answers

How do you programmatically set an attribute?

Suppose I have a python object x and a string s, how do I set the attribute s on x? So: >>> x = SomeObject() >>> attr = 'myAttr' >>> # magic goes here >>> x.myAttr 'magic' What's the magic? The goal of this, incidentally, is to cache calls to…
Nick
  • 21,555
  • 18
  • 47
  • 50
266
votes
7 answers

How to change an element's title attribute using jQuery

I have an form input element and want to change its title attribute. This has to be easy as pie, but for some reason I cannot find how to do this. How is this done, and where and how should I be searching on how to do this?
Brian
  • 8,147
  • 8
  • 34
  • 29
256
votes
7 answers

Set attribute without value

How do I set a data attribute without adding a value in jQuery? I want this: I tried: $('body').attr('data-body'); // this is a getter, not working $('body').attr('data-body', null); // not adding anything Everything else seems to…
David Hellsing
  • 106,495
  • 44
  • 176
  • 212
253
votes
17 answers

Select elements by attribute

I have a collection of checkboxes with generated ids and some of them have an extra attribute. Is it possible to use JQuery to check if an element has a specific attribute? For example, can I verify if the following element has the attribute…
Ciprian Grosu
  • 2,821
  • 3
  • 20
  • 14
250
votes
6 answers

Get Enum from Description attribute

Possible Duplicate: Finding an enum value by its Description Attribute I have a generic extension method which gets the Description attribute from an Enum: enum Animal { [Description("")] NotSet = 0, [Description("Giant Panda")] …
fearofawhackplanet
  • 52,166
  • 53
  • 160
  • 253
242
votes
7 answers

Iterate over object attributes in python

I have a python object with several attributes and methods. I want to iterate over object attributes. class my_python_obj(object): attr1='a' attr2='b' attr3='c' def method1(self, etc, etc): #Statements I want to generate…
Pablo Mescher
  • 26,057
  • 6
  • 30
  • 33
240
votes
1 answer

What’s the purpose of the HTML "nonce" attribute for script and style elements?

W3C says there is a new attribute in HTML5.1 called nonce for style and script that can be used by the Content Security Policy of a website. I googled about it but finally didn't get it what actually this attribute does and what changes when using…
ata
  • 3,398
  • 5
  • 20
  • 31
240
votes
5 answers

What is the point of noreturn?

[dcl.attr.noreturn] provides the following example: [[ noreturn ]] void f() { throw "error"; // OK } but I do not understand what is the point of [[noreturn]], because the return type of the function is already void. So, what is the point…
BЈовић
  • 62,405
  • 41
  • 173
  • 273
239
votes
8 answers

Python function attributes - uses and abuses

Not many are aware of this feature, but Python's functions (and methods) can have attributes. Behold: >>> def foo(x): ... pass ... >>> foo.score = 10 >>> dir(foo) ['__call__', '__class__', '__delattr__', '__dict__', '__doc__', '__get__',…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
211
votes
10 answers

Extracting an attribute value with beautifulsoup

I am trying to extract the content of a single "value" attribute in a specific "input" tag on a webpage. I use the following code: import urllib f = urllib.urlopen("http://58.68.130.147") s = f.read() f.close() from BeautifulSoup import…
Barnabe
  • 2,235
  • 2
  • 14
  • 6
195
votes
20 answers

Getting attributes of a class

I want to get the attributes of a class, say: class MyClass(): a = "12" b = "34" def myfunc(self): return self.a using MyClass.__dict__ gives me a list of attributes and functions, and even functions like __module__ and __doc__. While…
Mohamed Khamis
  • 7,731
  • 10
  • 38
  • 58
192
votes
20 answers

Get all Attributes from a HTML element with Javascript/jQuery

I want to put all attributes in a Html element into an array: like i have a jQuery Object, whichs html looks like this: now one way is to use the xml parser described here, but then i need to know how to…
k0ni
  • 2,417
  • 4
  • 22
  • 25
185
votes
5 answers

Are complex expressions possible in ng-hide / ng-show?

I want to do so: ng-hide="!globals.isAdmin && mapping.is_default" but the expression evaluates always to false. I do not want to define special function on $scope.
Paul
  • 25,812
  • 38
  • 124
  • 247
172
votes
8 answers

How enumerate all classes with custom class attribute?

Question based on MSDN example. Let's say we have some C# classes with HelpAttribute in standalone desktop application. Is it possible to enumerate all classes with such attribute? Does it make sense to recognize classes this way? Custom attribute…
tomash
  • 12,742
  • 15
  • 64
  • 81
169
votes
1 answer

Getting the value of an attribute in XML

How would one get the value of attribute1 (blah) in the following xml using xslt:
Smern
  • 18,746
  • 21
  • 72
  • 90