0

I need to style the first/last word in submit button using jQuery or CSS.

Code below:

input.wpcf7-form-control.wpcf7-submit {
font-weight: 700;
}
   <div id="btnDiv" class="btnDiv"> <input type="submit" value="SUBMIT REQUEST" class="wpcf7-form-control wpcf7-submit"></div>

I want to change the first-word font weight to light, Is this possible?

Please note: I can't change my HTML code. This is a WordPress site. The Submit button coming from a plugin called 'Contact Form 7'.

Brian McCutchon
  • 8,354
  • 3
  • 33
  • 45
Ali
  • 1,326
  • 1
  • 17
  • 38

4 Answers4

2

If the snippet you've given has a parent element with id then you can just use the script below.

This will replace the <input> with <button> then applies the other answers.

document.getElementById('btnDiv').innerHTML = '<button type="submit" class="wpcf7-form-control wpcf7-submit"><span class="sub-text">SUBMIT</span> REQUEST</button>';
.sub-text{
  font-weight : 700;
}
<div id="btnDiv" class="btnDiv"> 
  <input type="submit" value="SUBMIT REQUEST" class="wpcf7-form-control wpcf7-submit">
</div>

Or if using jQuery you can use this instead:

$('#btnDiv').html('<button type="submit" class="wpcf7-form-control wpcf7-submit"><span class="sub-text">SUBMIT</span> REQUEST</button>');
.sub-text{
  font-weight : 700;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="btnDiv" class="btnDiv"> 
  <input type="submit" value="SUBMIT REQUEST" class="wpcf7-form-control wpcf7-submit">
</div>
dcangulo
  • 1,888
  • 1
  • 16
  • 48
0

Go into the contact 7 form generator remove the input tag [submit] and append the following

<style>
.sub-text{
  font-weight : 700;
}
</style>
<button type="submit" class="wpcf7-form-control wpcf7-submit"><span class="sub-text">SUBMIT</span> REQUEST</button>

You have a from, as long as you have a input/button type submit it should work the same way it worked with a [submit] tag

madalinivascu
  • 32,064
  • 4
  • 39
  • 55
0

Try using this!

document.getElementById("btnDiv").innerHTML = '<button type="submit" class="wpcf7-form-control wpcf7-submit"><span class="sub-text" style="font-weight : 700;">SUBMIT</span> REQUEST</button>';
<div id="btnDiv" class="btnDiv"> 
   <input type="submit" value="SUBMIT REQUEST" class="wpcf7-form-control wpcf7-submit">
</div>
Kung Fu Panda
  • 636
  • 10
  • 22
-2

You can try button tag instant of input button. See below snip.

.sub-text{
  font-weight : 700;
}
<button type="submit" class="wpcf7-form-control wpcf7-submit"><span class="sub-text">SUBMIT</span> REQUEST</button>
A.K.
  • 2,284
  • 3
  • 26
  • 35