Change Font style in text field using js

I’m trying to change font type, I use the code:
javascript:void($('[data-label=textfieldname]').css('text-decoration', 'underline'));

but it is not working ((

There’s a few things here…

  1. Your syntax is incorrect. You need “” around your textfieldname value:
    $(‘[data-label=“textfieldname”]’)

  2. Depending on the type of widget, axure often puts the actual element (text, input, etc) inside of a div with the attribute you’re using to select. In most cases applying the style to the parent div will not impact the child in the way you’re hoping. Here’s an example of the markup for a text field:

 <div id="u32" class="ax_default text_field" data-label="Search Box">
  <input id="u32_input" type="text" value="" style="color: rgb(153, 153, 153);">
</div>

You can use “.children()” to get to child elements and then look at the markup to determine which item in the array you need. I typically use the $axure(‘@widgetname’).getElementIds() to get the actual ID used and then append a string to the end to get the item. In the example above, the axure fucntion will return “u32” and then i’d append “_input” to get the element I need. The mark-up is slightly different for different widget types - so the correct way to do what you want to is going to depend on your actual implementation.

3.You may be able to accomplish what you’re trying to do natively in axure using interaction styles without JS. I.e. if it’s just text that needs to be underlined, you can set the selected formatting to be underlined and then set that widget to selected. Native solutions are always best…

1 Like

I’m trying to make some editor in Axure. So I need change font size, font type and etc. I have try all I know (I know a little) and now I don’t know what to do (( Please I will attach file and if you have time, help me.
textfld.rp (45.9 KB)

Here’s a quick sample for underline:

textfld.rp (50.1 KB)

1 Like

WOW, That is what I wanted, thank you very much