Bug Tracker

Modify

Ticket #8929 (closed feature: wontfix)

Opened 2 years ago

Last modified 2 years ago

Provide auto-trim option for .text()

Reported by: AlistairB Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.5.2
Keywords: needsreview Cc:
Blocking: Blocked by:

Description

I am constantly writing code like this:

var myId = $.trim($(".some-element").text());

It would be nice to have a leaner way to do this. eg.

var myId = $(".some-element").text(true);

var myId = $(".some-element").textTrim(); //there isprobably a better name for this

Change History

comment:1 Changed 2 years ago by timmywil

  • Keywords needsreview added
  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to manipulation
  • Type changed from enhancement to feature

comment:2 Changed 2 years ago by ajpiano

If you do this a lot, write a utility function.

$.fn.textTrim = function() { 
return $.trim(this.text());
}

I don't think we should add this to core.

comment:3 Changed 2 years ago by rwaldron

  • Status changed from open to closed
  • Resolution set to wontfix

Second ajpiano

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.