2

I want to set the title of my textbox using css. It is possible via jquery but I want to set it via css.

Singh
  • 554
  • 6
  • 22
  • 2
    If CSS were to be used to set attributes, then what is the role of HTML markup? – Abhitalks Jan 17 '14 at 11:47
  • Any reason why you need to do this? – Nitesh Jan 17 '14 at 11:49
  • 1
    css can't change values of attributes. Plain js is enough for this task (jQuery not strictly necessary) – Fabrizio Calderan Jan 17 '14 at 11:49
  • I want to add title to class that is added to element at runtime. – Singh Jan 17 '14 at 11:52
  • you don't add title to class. you add that to element. – Abhitalks Jan 17 '14 at 11:54
  • @Fabrizio I dont want to change the existing value. I want to bind the static text with that class – Singh Jan 17 '14 at 11:55
  • @KulbirSingh a fiddle with a description would help a lot – Fabrizio Calderan Jan 17 '14 at 11:56
  • I have class 'textClass' that is given to textbox. I want to bind the title to 'myClass' via css – Singh Jan 17 '14 at 11:57
  • do you mean you want to apply myClass to all textboxes with a specific title? – Abhitalks Jan 17 '14 at 11:58
  • No no, i dont want to select the element via title selector. I want to set the value of title attribute(custom texts) – Singh Jan 17 '14 at 12:00
  • I am confused why my question is declared duplicated the question that they suggested and said here is answer is totally different answer. I have said in my question that I want to do through css but suggested question's answer is done through jquery – Singh Jan 17 '14 at 12:02
  • @KulbirSingh: did you see Quentin's comment above? – Abhitalks Jan 17 '14 at 12:08
  • @Abhitalks for your comment "you don't add title to class. you add that to element", you are programmer bro, Its common sense I know title will be added to element but initially my element have no class, I am adding classes to my element at runtime, So thats why I used that term that means I want to add title ti my element accroding to class added at runtime – Singh Jan 23 '17 at 12:17
  • @KulbirSingh: Please go through [this](http://stackoverflow.com/help/mcve) and [this](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/). – Abhitalks Jan 23 '17 at 12:27
  • @Abhitalks bro thanks for sharing. but nothing was confusing in my question, as a developer everyone knows class would be applied to element and I am asking to apply title attribute to class (I used class term because class is applied at runtime) – Singh Jan 23 '17 at 14:34

1 Answers1

2

CSS has been designed for the design aspect of a website, not for the content of it. There exists a property called content though. Take a look at http://css-tricks.com/css-content/.

EDIT: With this you are only capable of adding Textnodes, not adding or changing attributes of any other nodes.

Thomas Leu
  • 826
  • 4
  • 13